That to has come up before but you "can't" short of locally and one-off editing your Makevars for R.
So the short answer (and here I am going to use the path on my Debian / Ubuntu system which has a handy shortcut of /etc/R
as a softlink into R's own etc/
directory):
edd@rob:~$ grep -- '-g' /etc/R/Makeconf | grep -v "^#"
CFLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-8T8CYO/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
CXXFLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-8T8CYO/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
CXX11FLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-8T8CYO/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
CXX14FLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-8T8CYO/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
CXX17FLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-8T8CYO/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
CXX20FLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-8T8CYO/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g $(LTO)
FCFLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-8T8CYO/r-base-4.0.3=. -fstack-protector-strong $(LTO_FC)
FFLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-8T8CYO/r-base-4.0.3=. -fstack-protector-strong $(LTO_FC)
SAFE_FFLAGS = -g -O2 -fdebug-prefix-map=/build/r-base-8T8CYO/r-base-4.0.3=. -fstack-protector-strong -msse2 -mfpmath=sse
TCLTK_LIBS = -L/usr/lib/x86_64-linux-gnu -ltcl8.6 -L/usr/lib/x86_64-linux-gnu -ltk8.6 -lX11 -lXss -lXext
edd@rob:~$
This is (in essence) a combination of three sources:
- things that R itself hardwires
- things that the distribution hardwires for
gcc
and friends
- things that package maintainer (me, actually) specifies for the distro
All this sets your CXXFLAGS
(and same for CXX11...
CXX14...
...).
You can then set
- your user-local values via
~/.R/Makevars
- your package-local values via
src/Makevars
The really weird thing is that even after the almost 25 years that we have no mechanism to edit and override this and selectively undo. I think I recall that for gcc
et al the rightmost value wins...
So to sum up, to be "sure" you'd have to edit out the -O0
value in your machine-local config file.