[gnome-control-center/wip/add-account: 1/7] Only enable _FORTIFY_SOURCE if optimization enabled



commit 563f6503f86ee8d6a227ad78ed63aee8f4b0ec10
Author: Stef Walter <stefw gnome org>
Date:   Mon Jun 4 10:39:34 2012 +0200

    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 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3ec7242..2bf29b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -311,9 +311,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"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]