Dear People,
I want to run gcc with optimisation turned on (-O2), and with -Wall (all
warnings) enabled, when using R CMD SHLIB. When I do make, which is
R CMD SHLIB -Wall -O2 cftp.c mcmc.c latticefn.c -lm
in this case, I get
faheem ~/research/cftp>make
R CMD SHLIB -Wall -O2 cftp.c mcmc.c latticefn.c -lm
make[1]: Entering directory `/home/faheem/research/cftp'
gcc -I/usr/lib/R/include -I/usr/local/include -mieee-fp
-D__NO_MATH_INLINES -fPIC -g -c cftp.c -o cftp.o
gcc -shared -o cftp.so cftp.o mcmc.o latticefn.o -L/usr/local/lib
make[1]: Leaving directory `/home/faheem/research/cftp'
faheem ~/research/cftp>
it doesn't look like the arguments -O2 and -Wall get passed down. Is there
some reason for this? I certainly would like error checking to be turned
on as much as possible.
While we are on the topic, it looked like make is involved in invoking a
command like R CMD SHLIB -Wall -O2 cftp.c mcmc.c latticefn.c -lm. This is
presumably done using clever pattern rules and/or substitutions. I am
curious about how this is done. Can someone point to me to the appropriate
portion of the source code?
Thanks in advance for any help.
Sincerely, Faheem Mitha.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
passing arguments to R CMD SHLIB
5 messages · Faheem Mitha, Brian Ripley, Kurt Hornik
On Tue, 13 Mar 2001, Faheem Mitha wrote:
Dear People, I want to run gcc with optimisation turned on (-O2), and with -Wall (all warnings) enabled, when using R CMD SHLIB. When I do make, which is R CMD SHLIB -Wall -O2 cftp.c mcmc.c latticefn.c -lm in this case, I get faheem ~/research/cftp>make R CMD SHLIB -Wall -O2 cftp.c mcmc.c latticefn.c -lm make[1]: Entering directory `/home/faheem/research/cftp' gcc -I/usr/lib/R/include -I/usr/local/include -mieee-fp -D__NO_MATH_INLINES -fPIC -g -c cftp.c -o cftp.o gcc -shared -o cftp.so cftp.o mcmc.o latticefn.o -L/usr/local/lib make[1]: Leaving directory `/home/faheem/research/cftp' faheem ~/research/cftp> it doesn't look like the arguments -O2 and -Wall get passed down. Is there some reason for this? I certainly would like error checking to be turned on as much as possible.
Well, no one said they would be! If you want to alter flags, they are set as CFLAGS R_HOME/etc/Makeconf or Makevars. I have -O2 -Wall -pedantic. I don't think you need -lm as R is linked against that.
While we are on the topic, it looked like make is involved in invoking a command like R CMD SHLIB -Wall -O2 cftp.c mcmc.c latticefn.c -lm. This is presumably done using clever pattern rules and/or substitutions. I am curious about how this is done. Can someone point to me to the appropriate portion of the source code?
SHLIB contains a call to
make -f Makevars -f ${R_HOME}/etc/Makeconf
so you could also set CFLAGS in Makevars. Nothing very clever....
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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 13 Mar 2001, Prof Brian D Ripley wrote:
On Tue, 13 Mar 2001, Faheem Mitha wrote:
it doesn't look like the arguments -O2 and -Wall get passed down. Is there some reason for this? I certainly would like error checking to be turned on as much as possible.
Well, no one said they would be! If you want to alter flags, they are set as CFLAGS R_HOME/etc/Makeconf or Makevars. I have -O2 -Wall -pedantic. I don't think you need -lm as R is linked against that.
Is it possible to set CFLAGS at the user level? I am usually not terribly
keen to alter system config files (Makeconf in this case). For one thing,
I don't always have root access on the systems I use, and for another I
tend to lose my changes when I upgrade.
Faheem.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 13 Mar 2001, Faheem Mitha wrote:
On Tue, 13 Mar 2001, Prof Brian D Ripley wrote:
On Tue, 13 Mar 2001, Faheem Mitha wrote:
it doesn't look like the arguments -O2 and -Wall get passed down. Is there some reason for this? I certainly would like error checking to be turned on as much as possible.
Well, no one said they would be! If you want to alter flags, they are set as CFLAGS R_HOME/etc/Makeconf or Makevars. I have -O2 -Wall -pedantic. I don't think you need -lm as R is linked against that.
Is it possible to set CFLAGS at the user level? I am usually not terribly keen to alter system config files (Makeconf in this case). For one thing, I don't always have root access on the systems I use, and for another I tend to lose my changes when I upgrade.
I did say so: use a file Makevars. You can only add that way. If you do cat > Makevars PKG_CPPFLAGS=-O2 -Wall ^D then that will be added to CFLAGS. If you lose changes, make them in the file config.site, and copy that in when you build a new version of R. Works for me!
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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian D Ripley writes:
On Tue, 13 Mar 2001, Faheem Mitha wrote:
On Tue, 13 Mar 2001, Prof Brian D Ripley wrote:
On Tue, 13 Mar 2001, Faheem Mitha wrote:
it doesn't look like the arguments -O2 and -Wall get passed down. Is there some reason for this? I certainly would like error checking to be turned on as much as possible.
Well, no one said they would be! If you want to alter flags, they are set as CFLAGS R_HOME/etc/Makeconf or Makevars. I have -O2 -Wall -pedantic. I don't think you need -lm as R is linked against that.
Is it possible to set CFLAGS at the user level? I am usually not terribly keen to alter system config files (Makeconf in this case). For one thing, I don't always have root access on the systems I use, and for another I tend to lose my changes when I upgrade.
I did say so: use a file Makevars. You can only add that way. If you do
cat > Makevars PKG_CPPFLAGS=-O2 -Wall ^D
then that will be added to CFLAGS.
If you lose changes, make them in the file config.site, and copy that in when you build a new version of R. Works for me!
My recommendation would be along the lines of the FAQ:
Suppose you have C code file for dynloading into R, but you want to
use `R CMD SHLIB' with compilation flags other than the default ones
(which were determined when R was built). You could change the file
``R_HOME'/etc/Makeconf' to reflect your preferences. If you are a
Bourne shell user, you can also pass the desired flags to Make (which
is used for controlling compilation) via the Make variable `MAKEFLAGS',
as in
MAKEFLAGS="CFLAGS=-O3" R CMD SHLIB *.c
-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._