Is there an easy way to override the compile options when installing packages from CRAN on Unix-style systems? I tried setting CFLAGS, CXXFLAGS, and FFLAGS but they are not picked up. For example (with a random package and adding -mtune only to try to get rid of the default) export CFLAGS="-march=native -mtune=native" export CXXFLAGS="-march=native -mtune=native" R CMD INSTALL gstat_0.9-60.tar.gz [...] gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c block.c -o block.o [...] I am building a custom system and I'd like to get rid of '-g' (won't debug on that system) and change '-mtune=generic' to '-march=native' (don't need compatibility with other systems). Is there an easy way of doing this for all packages I build? Allan (Currently re-compiling BLAS and friends with -march=native.)
Prof Brian Ripley
2009-Jun-12 10:08 UTC
[R] Changing CRAN package compile option defaults?
On Fri, 12 Jun 2009, Allan Engelhardt wrote:> Is there an easy way to override the compile options when installing packages > from CRAN on Unix-style systems? I tried setting CFLAGS, CXXFLAGS, and > FFLAGS but they are not picked up. > > For example (with a random package and adding -mtune only to try to get rid > of the default) > > export CFLAGS="-march=native -mtune=native" > export CXXFLAGS="-march=native -mtune=native" > R CMD INSTALL gstat_0.9-60.tar.gz > [...] > gcc -m64 -std=gnu99 -I/usr/include/R -I/usr/local/include -fpic -O2 -g > -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector > --param=ssp-buffer-size=4 -m64 -mtune=generic -c block.c -o block.o > [...] > > I am building a custom system and I'd like to get rid of '-g' (won't debug on > that system) and change '-mtune=generic' to '-march=native' (don't need > compatibility with other systems). > > Is there an easy way of doing this for all packages I build?Yes: read 'R Installation and Administration' section 6.3.3 (at least of the version on CRAN). Also, it seems likely that you should be building R itself with the options you want for packages: how to do that is discussed in the same manual. (Looks like this may be a pre-compiled Linux binary distribution of R, but we don't know, of course.) In that case you don't need to set anything else.> Allan > > (Currently re-compiling BLAS and friends with -march=native.)-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595