C compilation flags from R

Can you set the RC and C ++ flags at compile time when installing from R CMD INSTALL (in fact, in this particular case I want to disable compiler optimization, but ideally there is a general solution)?

I know that you can influence some parameters using --configure-args="..." , and I rather optimistically tried --configure-args="diable-optimization" , but to no avail. Similarly, I could also edit $RHOME/etc/Makeconf , but again this is not the solution I'm looking for (and not possible if I don't have the appropriate write permission).

I define my flags through an autoconf script and with the Makevars file in the package/src directory, if that matters.

+5
r
source share
3 answers

Yes, I use the ~/.R/Makevars file for this. It is also convenient to install CC and CXX for different compilers when, say, switches gcc versions or switches to llvm or ...

+4
source share

Dirk is a very useful discussion (as always) and definitely pointed me in the right direction. For my specific problem, in addition to the Makevars file, I had to pass arguments to configure . I have no idea why this is (and reading around is not normal, so maybe I did something wrong), but if anyone else has the same problem, use ~/R/Makevars in conjunction with for me the following arguments worked for configure / INSTALL .

 R CMD INSTALL --configure-args="CFLAGS=-g CXXFLAGS=-g" package.tar.gz 
+4
source share

I can confirm that the Makevars file is very useful (especially if you need to use "-L / my / libs" or "-I / my / includes" or other build flags).

For assembly, if you want to set the parameter for the site / machine, you can also change the variables in the Makeconf file (/ path / R / install / [lib64 / R /] etc / Makeconf).

However, like me, you still have some problems for managing and using libraries later, you can also install libraries with the ldpaths [1] file. This file contains R_LD_LIBRARY_PATH used by R. This variable is the equivalent of the known LD_LIBRARY_PATH on unix [2].

I just added some content (just before the comment on MacOS / Darwin) to this file (/ path / R / install / [lib64 / R /] etc. / ldpaths):

 if test -n "${LD_LIBRARY_PATH}"; then R_LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${R_LD_LIBRARY_PATH}" fi ## This is DYLD_FALLBACK_LIBRARY_PATH on Darwin (OS X) and 

Then you can dynamically manage your libraries, for example using "environment modules" or "lmod".

Note that you can change many other environment and R variables with all the files in the config / etc directory (Renviron, repositories, javaconf, Rprofile.site ...).

[1] https://support.rstudio.com/hc/en-us/community/posts/200645248-Setting-up-LD-LIBRARY-PATH-for-a-rsession

[2] http://www.tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

+1
source share

All Articles