Skip to content

Commit 44f7a8d

Browse files
committed
Disable _FORTIFY_SOURCE when enable-debug
Since enable-debug disables optimization entirely, _FORTIFY_SOURCE does nothing as it requires some kind of optimization enabled. It instead produces a bunch of useless warnings. So explicitly disable it when enable-debug so that those warnings are not produced.
1 parent a689c11 commit 44f7a8d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

configure.ac

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -749,12 +749,17 @@ if test x$use_hardening != xno; then
749749
AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"])
750750
AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"])
751751

752-
AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[
753-
AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[
754-
HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE"
752+
# When enable_debug is yes, all optimizations are disabled.
753+
# However, FORTIFY_SOURCE requires that there is some level of optimization, otherwise it does nothing and just creates a compiler warning.
754+
# Since FORTIFY_SOURCE is a no-op without optimizations, do not enable it when enable_debug is yes.
755+
if test x$enable_debug != xyes; then
756+
AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[
757+
AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[
758+
HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE"
759+
])
760+
HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2"
755761
])
756-
HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2"
757-
])
762+
fi
758763

759764
AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"])
760765
AX_CHECK_LINK_FLAG([[-Wl,--nxcompat]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"])

0 commit comments

Comments
 (0)