[Rd] Multiple -g flags in R CMD SHLIB

Dirk Eddelbuettel edd at debian.org
Fri Jul 25 17:32:23 CEST 2014


On 25 July 2014 at 15:30, Alan Benson wrote:
| Does anybody know why two "-g" flags appear in the call to gcc in R CMD 
| SHLIB
| 
| Example:
| 
| gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic *-g* -O2 
| -fstack-protector --param=ssp-buffer-size=4 -Wformat 
| -Werror=format-security -D_FORTIFY_SOURCE=2 *-g*  -c c_file1.c -o 
| c_object1.o
| 
| Surely it need only be listed once?

AFAIK the second entry does no harm. 

If you study the source code invoked by R CMD SHLIB (and the related
commands) you will noticed that several Make variables are reflected, some of
which you can set from the file Makeconf (on my systems in /etc/R/Makeconf
via a symlink, otherwise in $R_HOME/etc/ depending on where R_HOME is) as
well as other files, including variants in your home directory such as
~/.R/Makevars (my favourite for local configurations). As well as extra
environment variables -- this is all driven by how 'make' behaves, which is
well documented.

As your local admin, you are free to edit these config files as you see fit,
and/or use additional environment variables to tailor this.

But as the second invocation of -g has no additional side effect over the
first, nobody has seen fit to write a 'uniquefy()' filter for the arguments.

For what it is worth, the default values on my system are below.  Some of the
choices are driven by Debian Policy and affect Debian, Ubuntu and other
Debian derivatives.

Hope this helps,  Dirk


edd at max:~$ grep -- -g /etc/R/Makeconf 
# configure  '--prefix=/usr' '--with-cairo' '--with-jpeglib' '--with-readline' '--with-tcltk' '--with-system-bzlib' '--with-system-pcre' '--with-system-zlib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share/R/share' '--includedir=/usr/share/R/include' '--with-blas' '--with-lapack' '--enable-R-profiling' '--enable-R-shlib' '--enable-memory-profiling' '--without-recommended-packages' '--build' 'x86_64-linux-gnu' 'build_alias=x86_64-linux-gnu' 'R_PRINTCMD=/usr/bin/lpr' 'R_PAPERSIZE=letter' 'R_BROWSER=xdg-open' 'LIBnn=lib' 'CC=gcc -std=gnu99' 'CFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro' 'CPPFLAGS=' 'F77=gfortran' 'FFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4' 'CXX=g++' 'CXXFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g' 'FC=gfortran' 'FCFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4'
CFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g $(LTO)
CXXFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g $(LTO)
CXX1XFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g
FCFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 $(LTO)
FFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 $(LTO)
SAFE_FFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -ffloat-store
TCLTK_LIBS = -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -L/usr/lib/x86_64-linux-gnu -ltk8.6 -lX11 -lXss -lXext
edd at max:~$ 
-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the R-devel mailing list