This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 1/2] BZ#10375: Configure magic to use -U_FORTIFY_SOURCE if needed.
- From: Roland McGrath <roland at hack dot frob dot com>
- To: libc-alpha at sourceware dot org
- Date: Mon, 7 May 2012 16:06:50 -0700 (PDT)
- Subject: [PATCH 1/2] BZ#10375: Configure magic to use -U_FORTIFY_SOURCE if needed.
- References: <20120507230613.1D8222C06E@topped-with-meat.com>
---
ChangeLog | 8 ++++++++
config.make.in | 2 +-
configure | 35 +++++++++++++++++++++++++++++++++++
configure.in | 14 ++++++++++++++
4 files changed, 58 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b80b485..338b418 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-05-07 Roland McGrath <roland@hack.frob.com>
+
+ [BZ #10375]
+ * configure.in: Check for _FORTIFY_SOURCE being predefined.
+ (CPPUNDEFS): New substituted variable; add -U_FORTIFY_SOURCE if needed.
+ * configure: Regenerated.
+ * config.make.in (CPPFLAGS-config): Prepend @CPPUNDEFS@.
+
2012-05-07 Joseph Myers <joseph@codesourcery.com>
[BZ #13885]
diff --git a/config.make.in b/config.make.in
index 5f6f9e2..3641fb2 100644
--- a/config.make.in
+++ b/config.make.in
@@ -102,7 +102,7 @@ CC = @CC@
CXX = @CXX@
BUILD_CC = @BUILD_CC@
CFLAGS = @CFLAGS@
-CPPFLAGS-config = @CPPFLAGS@
+CPPFLAGS-config = @CPPUNDEFS@ @CPPFLAGS@
ASFLAGS-config = @ASFLAGS_config@
AR = @AR@
MAKEINFO = @MAKEINFO@
diff --git a/configure b/configure
index 1c5f4ad..8bea2e1 100755
--- a/configure
+++ b/configure
@@ -632,6 +632,7 @@ libc_cv_localedir
libc_cv_slibdir
old_glibc_headers
libc_cv_gcc_unwind_find_fde
+CPPUNDEFS
sizeof_long_double
EGREP
GREP
@@ -7519,6 +7520,40 @@ _ACEOF
sizeof_long_double=$ac_cv_sizeof_long_double
+CPPUNDEFS=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FORTIFY_SOURCE predefine" >&5
+$as_echo_n "checking for _FORTIFY_SOURCE predefine... " >&6; }
+if ${libc_cv_predef_fortify_source+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+#ifdef _FORTIFY_SOURCE
+# error bogon
+#endif
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ libc_cv_predef_fortify_source=no
+else
+ libc_cv_predef_fortify_source=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_predef_fortify_source" >&5
+$as_echo "$libc_cv_predef_fortify_source" >&6; }
+if test $libc_cv_predef_fortify_source = yes; then
+ CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE"
+fi
+
+
### End of automated tests.
### Now run sysdeps configure fragments.
diff --git a/configure.in b/configure.in
index 19a2c1a..6f3e98e 100644
--- a/configure.in
+++ b/configure.in
@@ -2020,6 +2020,20 @@ AC_CHECK_SIZEOF(long double, 0)
sizeof_long_double=$ac_cv_sizeof_long_double
AC_SUBST(sizeof_long_double)
+CPPUNDEFS=
+dnl Check for silly hacked compilers predefining _FORTIFY_SOURCE.
+AC_CACHE_CHECK([for _FORTIFY_SOURCE predefine], libc_cv_predef_fortify_source,
+[AC_TRY_COMPILE([], [
+#ifdef _FORTIFY_SOURCE
+# error bogon
+#endif],
+ [libc_cv_predef_fortify_source=no],
+ [libc_cv_predef_fortify_source=yes])])
+if test $libc_cv_predef_fortify_source = yes; then
+ CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE"
+fi
+AC_SUBST(CPPUNDEFS)
+
### End of automated tests.
### Now run sysdeps configure fragments.
--
1.7.7.3