summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-02-21 17:13:12 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-04-26 18:55:10 +0100
commit8423a42999ff625a61e43f8acc55a4522ebc8c26 (patch)
tree3e7d85d3f6953d1a25d2ba58de75a3565b1344e3
parent2040f53bd3f2d48a2d33a737110920c112a28ea4 (diff)
downloaddbus-8423a42999ff625a61e43f8acc55a4522ebc8c26.tar.gz
Add support for --disable-gc-sections for broken toolchains
Also use AC_LINK_IFELSE rather than reinventing it as a shell function. This was the last user of ld_supports_flag, so, delete it. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33466 Reviewed-by: Colin Walters <walters@verbum.org>
-rw-r--r--configure.ac64
1 files changed, 26 insertions, 38 deletions
diff --git a/configure.ac b/configure.ac
index 459133c0..dcae206c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1117,38 +1117,6 @@ cc_supports_flag() {
test "x$rc" = xyes
}
-ld_supports_flag() {
- AC_MSG_CHECKING([whether $LD supports "$@"])
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[
- 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
-}
-
# Don't bother with -Werror on Windows for now, too many warnings
if test x$dbus_win != xyes -a x$dbus_cygwin != xyes -a x$USE_MAINTAINER_MODE = xyes; then
if cc_supports_flag "-Werror"; then
@@ -1279,13 +1247,33 @@ dnl block.
fi
fi]
-if ld_supports_flag --gc-sections; then
- SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
- CFLAGS="-ffunction-sections -fdata-sections $CFLAGS"
+# Disabling gc-sections makes our binaries bigger, but some toolchains
+# have known-broken support for it which discards sections that are needed.
+# See https://bugs.freedesktop.org/show_bug.cgi?id=33466
+SECTION_LDFLAGS=
+AC_ARG_ENABLE([gc-sections],
+ [AS_HELP_STRING([--disable-gc-sections],
+ [disable --gc-sections to work around broken toolchains])],
+ [enable_gc_sections=$enableval],
+ [enable_gc_sections=yes])
+if test "x$GCC,$enable_gc_sections,$dbus_win" = xyes,yes,no; then
+ save_CFLAGS="$CFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+ AC_MSG_CHECKING([for ability to link with --gc-sections])
+ CFLAGS="-ffunction-sections -fdata-sections"
+ LDFLAGS="-Wl,--gc-sections"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
+ [rc=yes],
+ [rc=no])
+ AC_MSG_RESULT([$rc])
+ CFLAGS="$save_CFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ if test "x$rc" = xyes; then
+ SECTION_LDFLAGS="-Wl,--gc-sections"
+ CFLAGS="-ffunction-sections -fdata-sections $CFLAGS"
+ fi
fi
-AC_SUBST(SECTION_FLAGS)
-AC_SUBST(SECTION_LDFLAGS)
-AC_MSG_RESULT($ac_gcsections)
+AC_SUBST([SECTION_LDFLAGS])
case $host_os in
solaris*)