gnucash maint: Better test for conflict between optimization and FORTIFY_SOURCE
Mike Alexander
mta at code.gnucash.org
Fri May 2 18:14:24 EDT 2014
Updated via https://github.com/Gnucash/gnucash/commit/8c21aff5 (commit)
from https://github.com/Gnucash/gnucash/commit/ca480862 (commit)
commit 8c21aff5e1dc878f62ef42794524ba17c5601626
Author: Mike Alexander <mta at umich.edu>
Date: Fri May 2 18:02:08 2014 -0400
Better test for conflict between optimization and FORTIFY_SOURCE
diff --git a/configure.ac b/configure.ac
index 48f3ecd..db40582 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1316,22 +1316,21 @@ then
# This is gcc >= 3.4.x
warnFLAGS="${warnFLAGS} -Wdeclaration-after-statement"
fi
- else if test "`echo ${GCC_VERSION} | cut -d. -f1`" -ge 4; then
+ elif test "`echo ${GCC_VERSION} | cut -d. -f1`" -ge 4; then
+ AC_MSG_CHECKING(OK To use fortify source?)
# This is gcc >= 4.x.x
warnFLAGS="${warnFLAGS} -Wdeclaration-after-statement -Wno-pointer-sign"
# rpmbuild on FC4 forces this flag. Only add it when optimizing
- have_optimization=
- for flag in $CFLAGS; do
- tmp_flag=`echo $flag | sed -e 's,-O.,,'`
- if `echo $flag | grep -q -- '-O'` ; then
- have_optimization=yes
- fi
- done
-
- if test "x${have_optimization}" = xyes; then
- warnFLAGS="${warnFLAGS} -D_FORTIFY_SOURCE=2"
- fi
- fi
+ cflags_save="$CFLAGS"
+ CFLAGS="$AM_CFLAGS $CFLAGS -Werror -D_FORTIFY_SOURCE=2"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <stdio.h>
+ ]],
+ [[ printf( "%s\n", "Hello World!");]])],
+ [warnFLAGS="${warnFLAGS} -D_FORTIFY_SOURCE=2"
+ AC_MSG_RESULT(OK)],
+ [AC_MSG_RESULT(No)])
+ CFLAGS="$cflags_save"
fi
CFLAGS="${warnFLAGS} ${CFLAGS}"
else
Summary of changes:
configure.ac | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
More information about the gnucash-changes
mailing list