aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-10-02 19:52:31 -0400
committerAndrew Chow <achow101-github@achow101.com>2019-10-07 14:11:40 -0400
commit44f7a8d7a774f82417106c452d793e6f091bc23e (patch)
treeddcee2844d7bf38f9d8b75bc28d289e36b45ef94 /configure.ac
parenta689c119076c7b8dc5b4dea4539e4cbf5adfb72f (diff)
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.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac15
1 files changed, 10 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac
index 8af9a986d2..a86a876d4f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -749,12 +749,17 @@ if test x$use_hardening != xno; then
AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"])
AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"])
- AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[
- AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[
- HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE"
+ # When enable_debug is yes, all optimizations are disabled.
+ # However, FORTIFY_SOURCE requires that there is some level of optimization, otherwise it does nothing and just creates a compiler warning.
+ # Since FORTIFY_SOURCE is a no-op without optimizations, do not enable it when enable_debug is yes.
+ if test x$enable_debug != xyes; then
+ AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[
+ AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[
+ HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE"
+ ])
+ HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2"
])
- HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2"
- ])
+ fi
AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"])
AX_CHECK_LINK_FLAG([[-Wl,--nxcompat]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"])