Re: [R-SIG-Mac] Building R-devel from source (solved)

2019-08-29 Thread Prof Brian Ripley

On 19/08/2019 15:00, peter dalgaard wrote:

OK, I now got a clang7 build running on a machine here too.

Simon, if you are listening: The alternative instructions to installing SDK to 
/usr/include seems to be incomplete. With

CPPFLAGS="-isysroot 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"

I got a succesful compile, but the link phase dies looking for -lSystem or 
somesuch. I.e., I think something needs to happen with LDFLAGS as well. This of 
course only shows up if you do not install the SDK to /usr/include.


The trick seems to be to include -isysroot as part of CC:

CC="/usr/local/clang8/bin/clang -isysroot 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"


and similarly for CXX.

Otherwise you are going to need something like

LDFLAGS="-L/usr/local/clang8/lib -L/usr/local/lib 
-L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"


I also had to set

CXXCPP="$CXX -E"

[There are quite a few places in configure which run ${CC} ${CFLAGS} -o 
foo.o -c foo.c


and so do not notice CPPFLAGS.]

I did not find this documented for clang (except for making pre-compiled 
headers), but gcc has at 
https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html


-isysroot dir

This option is like the --sysroot option, but applies only to 
header files (except for Darwin targets, where it applies to both header 
files and libraries). See the --sysroot option for more information.


and clang usually blindly copies gcc (I found a Q from a clang developer 
asking why it was like that in gcc).


I am revising the R-admin manual: will have a new version up in a few days.




-pd


On 19 Aug 2019, at 11:54 , Göran Broström  wrote:

Here is the report I promised. I followed the path below:

1. Got source from CRAN.

2. Read instructions under "Download R for (Mac) OS X"
(shouldn't that read "Download R for macOS" nowadays?). Especially the note Important: 
"If you wish to compile R packages ..., see the tools directory."

3. In the tools directory: Download and install clang-7.0.0.pkg (I see now that I should 
have chosen clang-8.0.0 for R 3.7.0, which is R-devel?). Also download and install 
gfortran-6.1.pkg (It says: "To be used with El Capitan builds of R.", which 
worried me a little, since I am on High Sierra, but there were no alternatives.)

With this setup I got my first reported error. Thanks to Peter, I went on to

https://cran.r-project.org/doc/manuals/r-release/Radmin.html#macOS,

where I read

--
One way to use these builds with a binary distribution of R is to have a 
~/.R/Makevars file similar to (El Capitan)

FC = /usr/local/gfortran/bin/gfortran
FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0
  -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm

or (Sierra or High Sierra)

FC = /usr/local/gfortran/bin/gfortran
FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0
  -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
--

I naively chose the "Sierra or High Sierra" alternative, but that was wrong as you can 
see: It apparently refers to gfortran 6.3, so I switched to the the "El Capitan" 
alternative.

The final error message was then something about 'unable to compile mixed C and 
Fortran code', and that was fixed by changing

LDFLAGS="-L/usr/local/clang7/lib -L/usr/local/lib"

to

LDFLAGS="-L/usr/local/clang7/lib -L/usr/local/gfortran/lib
-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0"

and voila, ./configure run without complaints!

The later build also went smoothly (but I had to install java).

So, to sum up, there seems to be some discrepancy between the two
instruction sets I tried to follow.

Göran




Den 2019-08-19 kl. 00:06, skrev Göran Broström:

Den 2019-08-18 kl. 22:16, skrev peter dalgaard:

/usr/local/clang7 is likely a better place to look. Check out Appendix C.3 of the R 
Inst. manual:

https://cran.r-project.org/doc/manuals/r-release/R-admin.html#macOS

That's better! After correcting some obvious(?) errors(?) in that page, 
./configure run without errors! (Had only read mac.r-procject.org/tools/ so 
far).
After a night's sleep I will 'make'. I'll report back to r-sig-mac.
Thanks, Göran


-pd


On 18 Aug 2019, at 21:35 , Göran Broström  wrote:

Update: There is a libgcc_s.1.dylib in /usr/lib, as a symlink to 
/usr/lib/libSystem.B.dylib. Is that one useful?

Göran

Den 2019-08-18 kl. 18:54, skrev Göran Broström:

Thanks Peter,
The tripping lines are here
configure:24611: checking size of size_t
configure:24616: gcc -o conftest -g -O2 -I/usr/local/include -L/usr/local/lib 
conftest.c -ldl -lm  >\
&5
configure:24616: $? = 0
configure:24616: ./conftest
dyld: Library not loaded: /usr/local/lib/libgcc_s.1.dylib
Referenced from: /Users/gb/R/src/R-devel/./conftest
Reason: image not found
so it seems as if my installation of tools is lacking an essential part 
(/usr/local/lib/libgcc_s.1.dylib). I'll look around, but any suggestion is 
welcome!
Göran
Den 2019-08-18 kl. 17:56, skrev peter dalgaard:

I 

Re: [R-SIG-Mac] Building R-devel from source (solved)

2019-08-19 Thread peter dalgaard
OK, I now got a clang7 build running on a machine here too.

Simon, if you are listening: The alternative instructions to installing SDK to 
/usr/include seems to be incomplete. With

CPPFLAGS="-isysroot 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"

I got a succesful compile, but the link phase dies looking for -lSystem or 
somesuch. I.e., I think something needs to happen with LDFLAGS as well. This of 
course only shows up if you do not install the SDK to /usr/include.

-pd

> On 19 Aug 2019, at 11:54 , Göran Broström  wrote:
> 
> Here is the report I promised. I followed the path below:
> 
> 1. Got source from CRAN.
> 
> 2. Read instructions under "Download R for (Mac) OS X"
> (shouldn't that read "Download R for macOS" nowadays?). Especially the note 
> Important: "If you wish to compile R packages ..., see the tools directory."
> 
> 3. In the tools directory: Download and install clang-7.0.0.pkg (I see now 
> that I should have chosen clang-8.0.0 for R 3.7.0, which is R-devel?). Also 
> download and install gfortran-6.1.pkg (It says: "To be used with El Capitan 
> builds of R.", which worried me a little, since I am on High Sierra, but 
> there were no alternatives.)
> 
> With this setup I got my first reported error. Thanks to Peter, I went on to
> 
> https://cran.r-project.org/doc/manuals/r-release/Radmin.html#macOS,
> 
> where I read
> 
> --
> One way to use these builds with a binary distribution of R is to have a 
> ~/.R/Makevars file similar to (El Capitan)
> 
> FC = /usr/local/gfortran/bin/gfortran
> FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0
>  -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
> 
> or (Sierra or High Sierra)
> 
> FC = /usr/local/gfortran/bin/gfortran
> FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0
>  -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
> --
> 
> I naively chose the "Sierra or High Sierra" alternative, but that was wrong 
> as you can see: It apparently refers to gfortran 6.3, so I switched to the 
> the "El Capitan" alternative.
> 
> The final error message was then something about 'unable to compile mixed C 
> and Fortran code', and that was fixed by changing
> 
> LDFLAGS="-L/usr/local/clang7/lib -L/usr/local/lib"
> 
> to
> 
> LDFLAGS="-L/usr/local/clang7/lib -L/usr/local/gfortran/lib
> -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0"
> 
> and voila, ./configure run without complaints!
> 
> The later build also went smoothly (but I had to install java).
> 
> So, to sum up, there seems to be some discrepancy between the two
> instruction sets I tried to follow.
> 
> Göran
> 
> 
> 
> 
> Den 2019-08-19 kl. 00:06, skrev Göran Broström:
>> Den 2019-08-18 kl. 22:16, skrev peter dalgaard:
>>> /usr/local/clang7 is likely a better place to look. Check out Appendix C.3 
>>> of the R Inst. manual:
>>> 
>>> https://cran.r-project.org/doc/manuals/r-release/R-admin.html#macOS
>> That's better! After correcting some obvious(?) errors(?) in that page, 
>> ./configure run without errors! (Had only read mac.r-procject.org/tools/ so 
>> far).
>> After a night's sleep I will 'make'. I'll report back to r-sig-mac.
>> Thanks, Göran
>>> 
>>> -pd
>>> 
 On 18 Aug 2019, at 21:35 , Göran Broström  wrote:
 
 Update: There is a libgcc_s.1.dylib in /usr/lib, as a symlink to 
 /usr/lib/libSystem.B.dylib. Is that one useful?
 
 Göran
 
 Den 2019-08-18 kl. 18:54, skrev Göran Broström:
> Thanks Peter,
> The tripping lines are here
> configure:24611: checking size of size_t
> configure:24616: gcc -o conftest -g -O2 -I/usr/local/include 
> -L/usr/local/lib conftest.c -ldl -lm  >\
> &5
> configure:24616: $? = 0
> configure:24616: ./conftest
> dyld: Library not loaded: /usr/local/lib/libgcc_s.1.dylib
>Referenced from: /Users/gb/R/src/R-devel/./conftest
>Reason: image not found
> so it seems as if my installation of tools is lacking an essential part 
> (/usr/local/lib/libgcc_s.1.dylib). I'll look around, but any suggestion 
> is welcome!
> Göran
> Den 2019-08-18 kl. 17:56, skrev peter dalgaard:
>> I can't claim to understand this, but on my system of same age, using 
>> system clang, configure does complete. It does get that error on line 
>> 23748, but that, and several similar subsequent tests just end up 
>> returning "yes".
>> 
>> configure:23748: checking for size_t
>> configure:23748: gcc -arch x86_64 -c -g -O2 -I/usr/local/include 
>> conftest.c >&5
>> configure:23748: $? = 0
>> configure:23748: gcc -arch x86_64 -c -g -O2 -I/usr/local/include 
>> conftest.c >&5
>> conftest.c:118:21: error: expected expression
>> if (sizeof ((size_t)))
>>   ^
>> 1 error generated.
>> [..snip..]
>> configure:23748: result: yes
>> 
>> (as usual, configure code is nigh on unreadable, but I think the logic 
>> is that the size_t 

Re: [R-SIG-Mac] Building R-devel from source (solved)

2019-08-19 Thread Göran Broström

Here is the report I promised. I followed the path below:

1. Got source from CRAN.

2. Read instructions under "Download R for (Mac) OS X"
 (shouldn't that read "Download R for macOS" nowadays?). Especially the 
note Important: "If you wish to compile R packages ..., see the tools 
directory."


3. In the tools directory: Download and install clang-7.0.0.pkg (I see 
now that I should have chosen clang-8.0.0 for R 3.7.0, which is 
R-devel?). Also download and install gfortran-6.1.pkg (It says: "To be 
used with El Capitan builds of R.", which worried me a little, since I 
am on High Sierra, but there were no alternatives.)


With this setup I got my first reported error. Thanks to Peter, I went 
on to


https://cran.r-project.org/doc/manuals/r-release/Radmin.html#macOS,

where I read

--
One way to use these builds with a binary distribution of R is to have a 
~/.R/Makevars file similar to (El Capitan)


FC = /usr/local/gfortran/bin/gfortran
FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0
  -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm

or (Sierra or High Sierra)

FC = /usr/local/gfortran/bin/gfortran
FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin16/6.3.0
  -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
--

I naively chose the "Sierra or High Sierra" alternative, but that was 
wrong as you can see: It apparently refers to gfortran 6.3, so I 
switched to the the "El Capitan" alternative.


The final error message was then something about 'unable to compile 
mixed C and Fortran code', and that was fixed by changing


LDFLAGS="-L/usr/local/clang7/lib -L/usr/local/lib"

to

LDFLAGS="-L/usr/local/clang7/lib -L/usr/local/gfortran/lib
-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0"

and voila, ./configure run without complaints!

The later build also went smoothly (but I had to install java).

So, to sum up, there seems to be some discrepancy between the two
instruction sets I tried to follow.

Göran




Den 2019-08-19 kl. 00:06, skrev Göran Broström:

Den 2019-08-18 kl. 22:16, skrev peter dalgaard:
/usr/local/clang7 is likely a better place to look. Check out Appendix 
C.3 of the R Inst. manual:


https://cran.r-project.org/doc/manuals/r-release/R-admin.html#macOS


That's better! After correcting some obvious(?) errors(?) in that page, 
./configure run without errors! (Had only read mac.r-procject.org/tools/ 
so far).


After a night's sleep I will 'make'. I'll report back to r-sig-mac.

Thanks, Göran



-pd


On 18 Aug 2019, at 21:35 , Göran Broström  wrote:

Update: There is a libgcc_s.1.dylib in /usr/lib, as a symlink to 
/usr/lib/libSystem.B.dylib. Is that one useful?


Göran

Den 2019-08-18 kl. 18:54, skrev Göran Broström:

Thanks Peter,
The tripping lines are here
configure:24611: checking size of size_t
configure:24616: gcc -o conftest -g -O2 -I/usr/local/include 
-L/usr/local/lib conftest.c -ldl -lm  >\

&5
configure:24616: $? = 0
configure:24616: ./conftest
dyld: Library not loaded: /usr/local/lib/libgcc_s.1.dylib
   Referenced from: /Users/gb/R/src/R-devel/./conftest
   Reason: image not found
so it seems as if my installation of tools is lacking an essential 
part (/usr/local/lib/libgcc_s.1.dylib). I'll look around, but any 
suggestion is welcome!

Göran
Den 2019-08-18 kl. 17:56, skrev peter dalgaard:
I can't claim to understand this, but on my system of same age, 
using system clang, configure does complete. It does get that error 
on line 23748, but that, and several similar subsequent tests just 
end up returning "yes".


configure:23748: checking for size_t
configure:23748: gcc -arch x86_64 -c -g -O2 -I/usr/local/include 
conftest.c >&5

configure:23748: $? = 0
configure:23748: gcc -arch x86_64 -c -g -O2 -I/usr/local/include 
conftest.c >&5

conftest.c:118:21: error: expected expression
if (sizeof ((size_t)))
  ^
1 error generated.
[..snip..]
configure:23748: result: yes

(as usual, configure code is nigh on unreadable, but I think the 
logic is that the size_t type exists if you can do "sizeof 
(size_t)", but not "sizeof ((size_t))", so the error is expected.)


The line that trips you up comes later:

configure:24611: checking size of size_t
configure:24616: gcc -arch x86_64 -o conftest -g -O2 
-I/usr/local/include -L/usr/

local/lib conftest.c -ldl -lm  >&5
configure:24616: $? = 0
configure:24616: ./conftest
configure:24616: $? = 0
configure:24630: result: 8

so that is where you should look for clues (or at least tell us 
what it says there).


-pd

On 18 Aug 2019, at 13:34 , Göran Broström  
wrote:


Hello,

I'm (for the first time) trying to build R-devel from source (to 
be able to check my CRAN packages on a Mac), but it breaks already 
after


gobr0002@MBP-2:~/R/src/R-devel$ ./configure

with

checking size of size_t... configure: error: in 
`/Users/gb/R/src/R-devel':

configure: error: cannot compute sizeof (size_t)
See `config.log' for more details

Some 'details' regarding size_t:

configure:23748: