From: Omar Sandoval <osan...@fb.com>

If CFLAGS contains -Wno-error, then the check for -D_FORTIFY_SOURCE=2
won't fail when appropriate. E.g., compiling with:

  ./configure CFLAGS='-Wno-error -O0' &&

Results in a flood of "_FORTIFY_SOURCE requires compiling with
optimization (-O)" warnings.

Make sure we add -Werror after the user-defined CFLAGS.

Signed-off-by: Omar Sandoval <osan...@fb.com>
---
 ChangeLog    | 5 +++++
 configure.ac | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index ed5f5866..ff012e3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-11  Omar Sandoval  <osan...@fb.com>
+
+       * configure.ac: Apply -Werror after user-defined CFLAGS in
+       -D_FORTIFY_SOURCE=2 check.
+
 2019-12-06  Mark Wielaard  <m...@klomp.org>
 
        * configure.ac: Add ac_cv_buildid check.
diff --git a/configure.ac b/configure.ac
index 36a6b6c2..25555d0b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -273,7 +273,7 @@ case "$CFLAGS" in
     ;;
   *)
     save_CFLAGS="$CFLAGS"
-    CFLAGS="-D_FORTIFY_SOURCE=2 -Werror $CFLAGS"
+    CFLAGS="-D_FORTIFY_SOURCE=2 $CFLAGS -Werror"
     AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
       #include <string.h>
       int main() { return 0; }
-- 
2.24.0

Reply via email to