aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/acinclude.m4
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/acinclude.m4')
-rw-r--r--libstdc++-v3/acinclude.m467
1 files changed, 44 insertions, 23 deletions
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index d4ddc494258..db63087d423 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -187,7 +187,7 @@ dnl safe (like an empty string).
dnl
dnl Defines:
dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
-dnl OPT_LDFLAGS='-Wl,-O1' if possible
+dnl OPT_LDFLAGS='-Wl,-O1' and '-z,relro' if possible
dnl LD (as a side effect of testing)
dnl Sets:
dnl with_gnu_ld
@@ -222,49 +222,70 @@ AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
# Start by getting the version number. I think the libtool test already
# does some of this, but throws away the result.
+ AC_MSG_CHECKING([for ld version])
changequote(,)
ldver=`$LD --version 2>/dev/null | head -1 | \
sed -e 's/GNU ld version \([0-9.][0-9.]*\).*/\1/'`
changequote([,])
glibcxx_gnu_ld_version=`echo $ldver | \
$AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
+ AC_MSG_RESULT($glibcxx_gnu_ld_version)
# Set --gc-sections.
- if test "$with_gnu_ld" = "notbroken"; then
- # GNU ld it is! Joy and bunny rabbits!
+ glibcxx_gcsections_min_ld=21602
+ if test x"$with_gnu_ld" = x"yes" &&
+ test $glibcxx_gnu_ld_version -gt $glibcxx_gcsections_min_ld ; then
- # All these tests are for C++; save the language and the compiler flags.
- # Need to do this so that g++ won't try to link in libstdc++
+ # Sufficiently young GNU ld it is! Joy and bunny rabbits!
+ # NB: This flag only works reliably after 2.16.1. Configure tests
+ # for this are difficult, so hard wire a value that should work.
+
+ # All these tests are for C++, but run with the "C" compiler driver.
+ # Need to do this so that g++ won't try to link in libstdc++/libsupc++.
ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
- CFLAGS='-x c++ -Wl,--gc-sections'
+ CFLAGS='-x c++ -Wl,--gc-sections'
# Check for -Wl,--gc-sections
- # XXX This test is broken at the moment, as symbols required for linking
- # are now in libsupc++ (not built yet). In addition, this test has
- # cored on solaris in the past. In addition, --gc-sections doesn't
- # really work at the moment (keeps on discarding used sections, first
- # .eh_frame and now some of the glibc sections for iconv).
- # Bzzzzt. Thanks for playing, maybe next time.
AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
- AC_TRY_RUN([
- int main(void)
- {
- try { throw 1; }
- catch (...) { };
- return 0;
- }
- ], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
+ AC_TRY_LINK([ int one(void) { return 1; }
+ int two(void) { return 2; }
+ ], [ two(); ] , [ac_gcsections=yes], [ac_gcsections=no])
+ if test "$ac_gcsections" = "yes"; then
+ rm -f conftest.c
+ touch conftest.c
+ if $CC -c conftest.c; then
+ if $LD --gc-sections -o conftest conftest.o 2>&1 | \
+ grep "Warning: gc-sections option ignored" > /dev/null; then
+ ac_gcsections=no
+ fi
+ fi
+ rm -f conftest.c conftest.o conftest
+ fi
+ if test "$ac_gcsections" = "yes"; then
+ SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
+ fi
+ AC_MSG_RESULT($ac_gcsections)
+
if test "$ac_test_CFLAGS" = set; then
CFLAGS="$ac_save_CFLAGS"
else
# this is the suspicious part
CFLAGS=''
fi
- if test "$ac_sectionLDflags" = "yes"; then
- SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
+ fi
+
+ # Set -z,relro.
+ # Note this is only for shared objects.
+ ac_ld_relro=no
+ if test x"$with_gnu_ld" = x"yes"; then
+ AC_MSG_CHECKING([for ld that supports -Wl,-z,relro])
+ cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"`
+ if test -n "$cxx_z_relo"; then
+ OPT_LDFLAGS="-Wl,-z,relro"
+ ac_ld_relro=yes
fi
- AC_MSG_RESULT($ac_sectionLDflags)
+ AC_MSG_RESULT($ac_ld_relro)
fi
# Set linker optimization flags.