From d2669b47812aebfe3ada7df4c7d7525790ef9c33 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 16 Jul 2012 14:24:29 +1000 Subject: Do not enable _FORTIFY_SOURCE without optimization With glibc-2.16, using -D_FORTIFY_SOURCE requires that optimization (-O) be used or it will prodice a warning message. Enable -Werror in our test for _FORTIFY_SOURCE support to catch when a users specifies CFLAGS without optimization. The line to set CFLAGS="" when no CFLAGS are specified (either due to being unset or geniunely empty) is required as autoconf will use "-O2 -g" for its tests by defult when CFLAGS is unset, but will not add them to the CFLAGS used... Signed-off-by: Allan McRae --- m4/acinclude.m4 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'm4') diff --git a/m4/acinclude.m4 b/m4/acinclude.m4 index 4455d261..f57a515e 100644 --- a/m4/acinclude.m4 +++ b/m4/acinclude.m4 @@ -40,11 +40,15 @@ AC_DEFUN([GCC_STACK_PROTECT_CC],[ dnl GCC_FORTIFY_SOURCE_CC dnl checks -D_FORTIFY_SOURCE with the C compiler, if it exists then updates -dnl CFLAGS +dnl CPPFLAGS AC_DEFUN([GCC_FORTIFY_SOURCE_CC],[ AC_LANG_ASSERT(C) if test "X$CC" != "X"; then AC_MSG_CHECKING(for FORTIFY_SOURCE support) + fs_old_cppflags="$CPPFLAGS" + fs_old_cflags="$CFLAGS" + CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2" + CFLAGS="$CFLAGS -Werror" AC_TRY_COMPILE([#include ], [ int main() { #if !(__GNUC_PREREQ (4, 1) ) @@ -54,10 +58,12 @@ AC_DEFUN([GCC_FORTIFY_SOURCE_CC],[ } ], [ AC_MSG_RESULT(yes) - CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2" + CFLAGS="$df_old_cflags" ], [ AC_MSG_RESULT(no) - ]) + CPPFLAGS="$df_old_cppflags" + CFLAGS="$df_old_cflags" + ]) fi ]) -- cgit v1.2.3-24-g4f1b