BZ#10375: Configure magic to use -U_FORTIFY_SOURCE if needed.
authorRoland McGrath <roland@hack.frob.com>
Mon, 14 May 2012 22:42:52 +0000 (15:42 -0700)
committerRoland McGrath <roland@hack.frob.com>
Wed, 16 May 2012 23:20:59 +0000 (16:20 -0700)
ChangeLog
Makeconfig
Makerules
config.make.in
configure
configure.in
time/ctime.c

index 95a4055..cde0173 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-05-16  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 (CPPUNDEFS): New substituted variable.
+       * Makeconfig (CPPFLAGS): Put $(CPPUNDEFS) at the beginning.
+       * Makerules ($(stdio_lim:h=st)): Use $(CPPUNDEFS).
+       * time/ctime.c: Don't #undef __OPTIMIZE__ and ctime.
+
 2012-05-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        * sysdeps/unix/sysv/linux/bits/mqueue.h: Include <bits/types.h>.
index f68a752..b81594f 100644 (file)
@@ -661,7 +661,8 @@ libio-include = -I$(..)libio
 # Note that we can't use -std=* in CPPFLAGS, because it overrides
 # the implicit -lang-asm and breaks cpp behavior for .S files--notably
 # it causes cpp to stop predefining __ASSEMBLER__.
-CPPFLAGS = $(CPPFLAGS-config) $($(subdir)-CPPFLAGS) $(+includes) $(defines) \
+CPPFLAGS = $(CPPUNDEFS) $(CPPFLAGS-config) $($(subdir)-CPPFLAGS) \
+          $(+includes) $(defines) \
           -include $(..)include/libc-symbols.h $(sysdep-CPPFLAGS) \
           $(CPPFLAGS-$(suffix $@)) \
           $(foreach lib,$(libof-$(basename $(@F))) \
index f374700..528077a 100644 (file)
--- a/Makerules
+++ b/Makerules
@@ -1233,7 +1233,7 @@ $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
          echo '#define _LIBC 1';                                       \
          echo '#include "$(..)misc/sys/uio.h"'; } |                    \
        $(CC) -E -dM -MD -MP -MF $(@:st=dT) -MT '$(@:st=h) $(@:st=d)'   \
-             $(+includes) -xc - -o $(@:st=hT)
+             $(CPPUNDEFS) $(+includes) -xc - -o $(@:st=hT)
        sed $(sed-remove-objpfx) $(sed-remove-dotdot)                   \
            $(@:st=dT) > $(@:st=dt)
        mv -f $(@:st=dt) $(@:st=d)
index 6c4d04e..4fa2608 100644 (file)
@@ -104,6 +104,7 @@ CXX = @CXX@
 BUILD_CC = @BUILD_CC@
 CFLAGS = @CFLAGS@
 CPPFLAGS-config = @CPPFLAGS@
+CPPUNDEFS = @CPPUNDEFS@
 ASFLAGS-config = @ASFLAGS_config@
 AR = @AR@
 MAKEINFO = @MAKEINFO@
index e664260..c295277 100755 (executable)
--- 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
@@ -7542,6 +7543,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.
 
index ce4b7ad..0916e9e 100644 (file)
@@ -2036,6 +2036,22 @@ 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.
+dnl Since we are building the implementations of the fortified functions here,
+dnl having the macro defined interacts very badly.
+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.
 
index 28321af..ca2d3ea 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#undef __OPTIMIZE__    /* Avoid inline `ctime' function.  */
 #include <time.h>
 
-#undef ctime
-
-
 /* Return a string as returned by asctime which
    is the representation of *T in that form.  */
 char *