forked from osmocom/wireshark
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
This commit is contained in:
parent
9a2dc60d72
commit
88c8b9218d
46
acinclude.m4
46
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
|
||||
#
|
||||
|
|
12
configure.in
12
configure.in
|
@ -436,12 +436,14 @@ else
|
|||
CPPFLAGS="-D_U_=\"\" $CPPFLAGS"
|
||||
fi
|
||||
|
||||
# If we're running GCC or CLang, always use FORTIFY_SOURCE=2
|
||||
# If we're running GCC or CLang, use FORTIFY_SOURCE=2
|
||||
# (only if the GCC 'optimization level' > 0).
|
||||
#
|
||||
# See: http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
|
||||
# Note: FORTIFY_SOURCE is only effective for gcc -O2 (and -O1 ?)
|
||||
if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
|
||||
CPPFLAGS="-D_FORTIFY_SOURCE=2 $CPPFLAGS"
|
||||
fi
|
||||
# See: http://sourceware.org/bugzilla/show_bug.cgi?id=13979
|
||||
#
|
||||
# Note: FORTIFY_SOURCE is only effective for gcc optimization level > 0 (-O1, etc)
|
||||
AC_WIRESHARK_GCC_FORTIFY_SOURCE_CHECK
|
||||
|
||||
#
|
||||
# If the compiler supports GCC-style flags, enable a barrier "stop on
|
||||
|
|
Loading…
Reference in New Issue