summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <johnp@redhat.com>2008-03-04 13:09:07 -0500
committerJohn (J5) Palmieri <johnp@redhat.com>2008-03-04 13:09:07 -0500
commitbd561f9a1941821c9c1d9266765b3a9d1b133e00 (patch)
treed1c5dfcd9edc644d1ef35d1680d78479062b8948
parentd511324fffd419bb6c5841d3a3bcc19eb1de45e5 (diff)
check if the linker supports a flag instead of just checking for GNU ld
* configure.in: move AM_PROG_LIBTOOL to the top (ld_supports_flag): new function for checking if the linker supports a given flag
-rw-r--r--ChangeLog8
-rw-r--r--configure.in60
2 files changed, 42 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 7a083f54..28497bc8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2008-03-04 John (J5) Palmieri <johnp@redhat.com>
+ * check if the linker supports a flag instead of just checking for GNU
+ ld
+ * configure.in: move AM_PROG_LIBTOOL to the top
+ (ld_supports_flag): new function for checking if the linker supports
+ a given flag
+
+2008-03-04 John (J5) Palmieri <johnp@redhat.com>
+
* add a changelog for Benjamin Reed's git patch RANT: Change Logs are
handled by git and having an external changelog just screws up
merging. We should write down rules for doing git commit messages
diff --git a/configure.in b/configure.in
index bb28708c..1caf7d92 100644
--- a/configure.in
+++ b/configure.in
@@ -60,6 +60,7 @@ AC_PROG_CXX
AC_ISC_POSIX
AC_HEADER_STDC
AC_C_INLINE
+AM_PROG_LIBTOOL
AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[enable unit test code]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no)
@@ -144,6 +145,36 @@ cc_supports_flag() {
return $rc
}
+ld_supports_flag() {
+ AC_MSG_CHECKING([whether $LD supports "$@"])
+ AC_TRY_LINK([
+ int one(void) { return 1; }
+ int two(void) { return 2; }
+ ], [ two(); ] , [_ac_ld_flag_supported=yes], [_ac_ld_flag_supported=no])
+
+ if test "$_ac_ld_flag_supported" = "yes"; then
+ rm -f conftest.c
+ touch conftest.c
+ if $CC -c conftest.c; then
+ ld_out=`$LD $@ -o conftest conftest.o 2>&1`
+ ld_ret=$?
+ if test $ld_ret -ne 0 ; then
+ _ac_ld_flag_supported=no
+ elif echo "$ld_out" | egrep 'option ignored|^usage:|unrecognized option|illegal option' >/dev/null ; then
+ _ac_ld_flag_supported=no
+ fi
+ fi
+ rm -f conftest.c conftest.o conftest
+ fi
+
+ AC_MSG_RESULT($_ac_ld_flag_supported)
+ if test "$_ac_ld_flag_supported" = "yes" ; then
+ return 0
+ else
+ return 1
+ fi
+}
+
if test "x$GCC" = "xyes"; then
changequote(,)dnl
case " $CFLAGS " in
@@ -214,7 +245,7 @@ if test "x$GCC" = "xyes"; then
*[\ \ ]-fPIC[\ \ ]*) ;;
*) if cc_supports_flag -fPIC; then
PIC_CFLAGS="-fPIC"
- if [ "x$with_gnu_ld" = "xyes" ]; then
+ if ld_supports_flag -z,relro; then
PIC_LDFLAGS="-Wl,-z,relro"
fi
fi
@@ -225,7 +256,7 @@ if test "x$GCC" = "xyes"; then
*[\ \ ]-fPIE[\ \ ]*) ;;
*) if cc_supports_flag -fPIE; then
PIE_CFLAGS="-fPIE"
- if [ "x$with_gnu_ld" = "xyes" ]; then
+ if ld_supports_flag -z,relro; then
PIE_LDFLAGS="-pie -Wl,-z,relro"
else
PIE_LDFLAGS="-pie"
@@ -280,28 +311,7 @@ AC_SUBST(PIC_LDFLAGS)
AC_SUBST(PIE_CFLAGS)
AC_SUBST(PIE_LDFLAGS)
-# Check for -Wl,--gc-sections
-AC_MSG_CHECKING([for ld that supports "-Wl,--gc-sections"])
-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
- ld_out=`$LD --gc-sections -o conftest conftest.o 2>&1`
- ld_ret=$?
- if test $ld_ret -ne 0 ; then
- ac_gcsections=no
- elif echo "$ld_out" | egrep 'option ignored|^usage:|illegal option' >/dev/null ; then
- ac_gcsections=no
- fi
- fi
- rm -f conftest.c conftest.o conftest
-fi
-if test "$ac_gcsections" = "yes"; then
+if ld_supports_flag --gc-sections; then
SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
CFLAGS="-ffunction-sections -fdata-sections $CFLAGS"
fi
@@ -316,8 +326,6 @@ case $target_os in
CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS" ;;
esac
-AM_PROG_LIBTOOL
-
changequote(,)dnl
# compress spaces in flags
CFLAGS=`echo "$CFLAGS" | sed -e 's/ +/ /g'`