I want to debug Rcpp based package using gdb
, but my R configuration is missing -fdebug-prefix-map
and it seems to be the cause that the debugger couldn't locate the line of errors. How can I configure this option?
# etc/Makeconf. Generated from Makeconf.in by configure.
#
# ${R_HOME}/etc/Makeconf
#
# R was configured using the following call
# (not including env. vars and site configuration)
# 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' 'TAR=/bin/tar' 'R_BROWSER=xdg-open' 'LIBnn=lib' 'JAVA_HOME=/usr/lib/jvm/default-java' 'R_SHELL=/bin/bash' 'CC=gcc -std=gnu99' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro' 'CPPFLAGS=' 'FC=gfortran' 'FCFLAGS=-g -O2 -fstack-protector-strong' 'CXX=g++' 'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g'
Here are my package compile messages.
g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I"/home/sasa/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include" -ggdb3 -Og -march=native -flto -Wall -Werror -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c train.cpp -o train.o
g++ -std=gnu++17 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o fast.beta.train.so RcppExports.o train.o -ggdb3 -Og -march=native -flto -Wall -Werror -L/usr/lib/R/lib -lR```
You can either
~/.R/Makevars
(preferred, probably) orMakeconf
in R's own etc/
(below $RHOME
) orsrc/Makevars
directlyto set this. There is no programmatic way, and you are discouraged by Policy to add it to per-package files so you can't do the third option in a CRAN package.