From d079041b14db5dc3fb10f6ac4e9c6700df2e956b Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 4 Jun 2012 10:39:34 +0200 Subject: [PATCH] build: Only enable _FORTIFY_SOURCE if optimization enabled Otherwise we get a spew of warnings when building non-optimized https://bugzilla.gnome.org/show_bug.cgi?id=677373 --- configure.ac | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8ea837ac8..a97dfcd66 100644 --- a/configure.ac +++ b/configure.ac @@ -312,9 +312,22 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then -Wuninitialized \ -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \ -Wnested-externs -Wpointer-arith \ - -Wcast-align -Wsign-compare -Wp,-D_FORTIFY_SOURCE=2 \ + -Wcast-align -Wsign-compare \ $CFLAGS" + # Only add this when optimizing is enabled (default) + AC_MSG_CHECKING([whether optimization is enabled]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if __OPTIMIZE__ == 0 + #error No optimization + #endif + ]], [[]])], + [has_optimization=yes], + [has_optimization=no]) + if test $has_optimization = yes; then + CFLAGS="$CFLAGS -Wp,-D_FORTIFY_SOURCE=2" + fi + AC_MSG_RESULT($has_optimization) + for option in -Wno-strict-aliasing -Wno-sign-compare; do SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $option"