FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 07-16-2012, 04:38 AM
Allan McRae
 
Default 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 <allan@archlinux.org>
---
configure.ac | 5 +++++
m4/acinclude.m4 | 12 +++++++++---
2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6f53c72..d37d978 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,6 +66,11 @@ LT_INIT
LIB_VERSION=`expr lib_current - lib_age`.lib_age.lib_revision
LIB_VERSION_INFO="lib_current:lib_revision:lib_age "

+# Respect empty CFLAGS during compiler tests
+if test "x$CFLAGS" != "x"; then
+ CFLAGS=""
+fi
+
# Set subsitution values for version stuff in Makefiles and anywhere else,
# and put LIB_VERSION in config.h
AC_SUBST(LIB_VERSION)
diff --git a/m4/acinclude.m4 b/m4/acinclude.m4
index 4455d26..f57a515 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 <features.h>], [
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
])

--
1.7.11.2
 

Thread Tools




All times are GMT. The time now is 06:47 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org