[R-SIG-Mac] error: unrecognized option ‘-arch’ -- suggestion!

Simon Urbanek simon.urbanek at r-project.org
Thu Sep 27 14:27:38 CEST 2012


On Sep 27, 2012, at 5:02 AM, Peder Axensten wrote:

> The compiler (clang) and linker that Apple includes (with Xcode) uses the argument -arch to specify the architecture to build for. This is not recognized by, for instance, the gcc compilers. Because this argument is 'hardcoded' into the Makeconfig files,

It is not - those (assuming you mean Makeconf) are generated from the flags used to build R, so if you use any other compiler with other flags they will be reflected in the Makeconf accordingly.


> it is an involved process to compile libraries for R with any other compiler.
> 


R doen't care what you compile libraries with as long as R can links against them at configure time. Again, this has nothing to do with Makevars.

Cheers,
Simon



> Either all all `-arch i386` and `-arch x86_64` must be removed from these files (this must be done every time R is updated) or you create a file `~/.R/Makevars` with something like
> ~~~~~~~
> MYARCH = -arch x86_64
> 
> # Comment the next line to return to the original setting:
> MYARCH = 
> 
> CC = gcc $(MYARCH) -std=gnu99
> CXX=g++ $(MYARCH)
> CXXCPP = g++ $(MYARCH) -E
> FC = gfortran $(MYARCH)
> F77 = gfortran $(MYARCH)
> OBJC = gcc $(MYARCH)
> OBJCXX = g++ $(MYARCH)
> 
> DYLIB_LD = gcc $(MYARCH) -std=gnu99
> MAIN_LD = gcc $(MYARCH) -std=gnu99
> SHLIB_CXXLD = g++ $(MYARCH)
> SHLIB_FCLD = gfortran $(MYARCH)
> SHLIB_LD = gcc $(MYARCH) -std=gnu99
> ~~~~~~~
> Unfortunately, a few instances of `-arch` are outside the variables and can not be reached this way.
> 
> 
> 
> My suggestion is that the Makeconfig files are slightly changed:
> 
> - Change all `-arch i386` or `-arch x86_64` in these files to `$(MYARCH)`.
> - Add a line `MYARCH = -arch x86_64` or `MYARCH = -arch i386`, respectively, to the top of these files.
> 
> No functionality is changed but using another compiler is more compatible and simpler as only MYARCH would need to be predefined.
> 
> 
> 
> Even better would be to be able to specify the compiler set to be used by using a variable (and handle the architecture accordingly), but I know to little about make files to come up with a constructive suggestion. Probably something like using
> PREFIX = 
> GCC = $(PREFIX)gcc $(MYARCH)
> GPP = $(PREFIX)g++ $(MYARCH)
> GFORTRAN = $(PREFIX)gfortran $(MYARCH)
> and then using them when defining CC, XXX, etc.
> 
> No functionality would be changed, but a different set of compilers could be used just by changing PREFIX and MYARCH.
> 
> Best regards,
> 
> Peder Axensten
> Research engineer
> 
> Swedish University of Agricultural Sciences
> Dept. of Forest Resource Management
> Remote Sensing
> se-90183 Umeå
> Sweden
> Visiting address: Skogsmarksgränd
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 
> 



More information about the R-SIG-Mac mailing list