From f8ac9df9e919464ca8b1430a5fe3416d67f34ece Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 1 Feb 2011 19:09:57 +0000 Subject: [PATCH 2/2] Allow --gc-sections to be disabled, again to work around broken toolchains Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33466 --- configure.in | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diff --git a/configure.in b/configure.in index 17d2a06..277a32a 100644 --- a/configure.in +++ b/configure.in @@ -1307,13 +1307,25 @@ fi AC_SUBST(PIE_CFLAGS) AC_SUBST(PIE_LDFLAGS) -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 +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]) +SECTION_CFLAGS= +SECTION_LDFLAGS= +if test "x$GCC,$enable_pie,$dbus_win" = xyes,yes,no; then + if ld_supports_flag --gc-sections && \ + cc_supports_flag -ffunction-sections && \ + cc_supports_flag -fdata-sections; 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) case $host_os in solaris*) -- 1.7.2.3