[Rcpp-devel] building RInside under debian

Jonathon Love jon at thon.cc
Sun Aug 30 16:09:08 CEST 2015


hi,

i'm building RInside on debian, and am interested in the hardening
arguments to g++

building RInside results in the following calls:

    g++ -I/usr/share/R/include -DNDEBUG -I. -I../inst/include/ 
-I"/usr/lib/R/site-library/Rcpp/include"   -fpic  -g -O2
-fstack-protector-strong -Wformat -Werror=format-security
-D_FORTIFY_SOURCE=2 -g  -c MemBuf.cpp -o MemBuf.o
    g++ -I/usr/share/R/include -DNDEBUG -I. -I../inst/include/ 
-I"/usr/lib/R/site-library/Rcpp/include"   -fpic  -g -O2
-fstack-protector-strong -Wformat -Werror=format-security
-D_FORTIFY_SOURCE=2 -g  -c RInside.cpp -o RInside.o
    g++ -shared -L/usr/lib/R/lib -Wl,-z,relro -o RInside.so MemBuf.o
RInside.o -L/usr/lib/R/lib -lR
    g++ -o libRInside.so MemBuf.o RInside.o -shared   -L/usr/lib/R/lib -lR

these are correct, and the hardening flags are present
(-D_FORTIFY_SOURCE, -Wl,-z,relro, etc. etc.), except for the fourth
command, which is lacking them. if i drill down in Makevars to the line:

    $(USERLIB): $(OBJECTS)
        $(SHLIB_CXXLD) -o $(USERLIB) $^ $(SHLIB_CXXLDFLAGS) $(ALL_LIBS)

then add a variable, and add it to the call:

HARDEN_LD = $(shell dpkg-buildflags --get LDFLAGS)

    $(USERLIB): $(OBJECTS)
        $(SHLIB_CXXLD) -o $(USERLIB) $^ $(SHLIB_CXXLDFLAGS) $(HARDEN_LD)
$(ALL_LIBS)

then the hardening works correctly.

(i also tried SHLIB_CXXLDFLAGS += $(shell dpkg-buildflags --get
LDFLAGS), but that doesn't work, not sure why)

i'm wondering why this isn't working correctly by default. is there an
issue with my system? is the Makevars file not quite correct? is there a
"correct" way to achieve this without editing Makevars?

with thanks

jonathon

-- 

JASP - A Fresh Way to Do Statistics
http://jasp-stats.org/

--

How happy is he born and taught,
That serveth not another's will;
Whose armour is his honest thought,
And simple truth his utmost skill

This man is freed from servile bands
Of hope to rise, or fear to fall:
Lord of himself, though not of lands,
And, having nothing, yet hath all.

  -- Sir Henry Wotton



More information about the Rcpp-devel mailing list