Cherry-picked (and rebased) 94189645e67f364c4445d62e2b00c282d885cbbf from the “up for grabs” PR: “[build] Make –enable-debug pick better options” (#12695).
See previous review in #12695.
Cherry-picked (and rebased) 94189645e67f364c4445d62e2b00c282d885cbbf from the “up for grabs” PR: “[build] Make –enable-debug pick better options” (#12695).
See previous review in #12695.
Various changes:
* Don't check $GCC and $GXX
* Prefer -Og instead of -O0
* If -g3 isn't available, use -g
This also incidentally fixes compiler warnings with GCC and glibc when using
--enable-debug, as the old default values mixed poorly with the hardening flags.
One small thing that needs to be fixed before merge is that CPPFLAGS
, CXXFLAGS
and LDFLAGS
gets stuffed with redundant spaces when printing which looks a bit messy:
0$ ./configure
1…
2 CC = gcc
3 CFLAGS = -g -O2
4 CPPFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS
5 CXX = g++ -std=c++11
6 CXXFLAGS = -Wstack-protector -fstack-protector-all -g -O2 -Wall -Wextra -Wformat -Wvla -Wformat-security -Wno-unused-parameter
7 LDFLAGS = -pthread -Wl,-z,relro -Wl,-z,now -pie
8 ARFLAGS = cr
I’ll find a way to fix that.
Added a commit fixing the annoying extra whitespace:
0$ ./configure
1…
2 CC = gcc
3 CFLAGS = -g -O2
4 CPPFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS
5 CXX = g++ -std=c++11
6 CXXFLAGS = -Wstack-protector -fstack-protector-all -g -O2 -Wall -Wextra -Wformat -Wvla -Wformat-security -Wno-unused-parameter
7 LDFLAGS = -pthread -Wl,-z,relro -Wl,-z,now -pie
8 ARFLAGS = cr
Please review :-)
utACK 8a0ad1a2333b329d6eb8d34a25277181ee675f23. The first commit is just rebased and has no changes since my previous review in the other PR. The second commit is new and looks ok, though I think the echo_joined function is overkill. I think you should just drop quotes around the variables and let the shell collapse spaces:
0echo " CXXFLAGS =" $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $ERROR_CXXFLAGS $CXXFLAGS
AX_APPEND_COMPILE_FLAGS
. Could you help with a diff for that?
AX_APPEND_FLAG / AX_APPEND_COMPILE_FLAGS
changes.
250+ # Prefer -Og, fall back to -O0 if that is unavailable.
251+ AX_CHECK_COMPILE_FLAG(
252+ [-Og],
253+ [[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -Og"]],
254+ [AX_CHECK_COMPILE_FLAG([-O0],[[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -O0"]],,[[$CXXFLAG_WERROR]])],
255+ [[$CXXFLAG_WERROR]])
-Og
and -O0
are unavailable? (Both of these may compromise spectre mitigations, so I have my x86 compiler not support them at all)