aboutsummaryrefslogtreecommitdiffstats
path: root/acinclude.m4
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2012-07-07 22:35:55 +0000
committerBill Meier <wmeier@newsguy.com>2012-07-07 22:35:55 +0000
commit88c8b9218d11c7088b4c6a1b88eb839f64b52413 (patch)
treebbab2eba192d27ac0a317ff713e2c02c7fc2cc63 /acinclude.m4
parent9a2dc60d7265cea82873e0f5ab1439bd2ce1c33e (diff)
Use -D_FORTIFY_SOURCE=2 only if the gc optimization level is greater than 0.
Fixes Bug #7449: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7449 ----- Issue: Building Wireshark with '-O0 -D_FORTIFY_SOURCE=2 ...' fails The warning [error] message: /usr/include/features.h:314:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]` A bit of research shows that this warning was added to a recent version of glibc (on at least Fedora). See: http://sourceware.org/bugzilla/show_bug.cgi?id=13979 The warning message occurs if -D_FORTIFY_SOURCE=... is used and the gcc 'optimization level' == 0 (-O0). Unfortunately when building with -O0 this warning message: 1. Causes compiles to fail (if -Werror [stop on warning]) 2. Causes ./configure to fail with an (incorrect) message about the pcap header being older than the libpcap version. svn path=/trunk/; revision=43601
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m446
1 files changed, 46 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 1aa56a9f14..81e365784a 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1674,6 +1674,52 @@ else
fi
])
+# AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK
+#
+# Checks if '-D_FORTIFY_SOURCE=...' is OK to use in CPPFLAGS.
+# Use '-D_FORTIFY_SOURCE=...' in CPPFLAGS only if the GCC 'optimization level' is > 0.
+# The use of '-D_FORTIFY_SOURCE=...' will cause a warning with at least some versions
+# of glibc if the GCC "optimization level" is 0 (default or -O or -O0)
+# when using GCC to compile a source file which references the macro definition.
+#
+# See: http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
+# See: http://sourceware.org/bugzilla/show_bug.cgi?id=13979
+#
+# We'll use '-D_FORTIFY_SOURCE=2' only if there's no warning; Among other things this means
+# that the use of '-D_FORTIFY_SOURCE=2' with '-Werror' and '-O0' won't cause
+# the compiler to stop on error.
+# Assumption: CFLAGS already contains whatever optimization option including none) is
+# to be used.
+#
+
+AC_DEFUN([AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK],
+[
+if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
+ AC_MSG_CHECKING([whether -D_FORTIFY_SOURCE=... can be used (without generating a warning)])
+ CFLAGS_saved="$CFLAGS"
+ CPPFLAGS_saved="$CPPFLAGS"
+ CFLAGS="$CFLAGS -Werror"
+ CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+ #include <stdio.h>
+ int foo;
+ ]])],
+ [
+ AC_MSG_RESULT(yes)
+ #
+ # (CPPFLAGS contains _D_FORTIFY_SOURCE=2)
+ #
+ ],
+ [
+ AC_MSG_RESULT(no)
+ # Remove -D_FORTIFY_SOURCE=2
+ CPPFLAGS="$CPPFLAGS_saved"
+ ])
+ CFLAGS="$CFLAGS_saved"
+fi
+])
+
#
# AC_WIRESHARK_OSX_INTEGRATION_CHECK
#