From d7e0172e8cf88049b74ec0867e094cde86301a4b Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 15 Aug 2013 23:45:10 +0900 Subject: [PATCH] Bug 904979 - Force use gold, if possible, when the default linker is BFD ld, for local builds. r=ted --- build/autoconf/compiler-opts.m4 | 24 ++++++++++++++++++++++++ js/src/build/autoconf/compiler-opts.m4 | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/build/autoconf/compiler-opts.m4 b/build/autoconf/compiler-opts.m4 index f3d6a0d3333..4c56c565a76 100644 --- a/build/autoconf/compiler-opts.m4 +++ b/build/autoconf/compiler-opts.m4 @@ -115,6 +115,30 @@ if test -z "$GNU_CC"; then esac fi +if test "$GNU_CC" -a -n "$DEVELOPER_OPTIONS"; then + dnl if the default linker is BFD ld, check if gold is available and try to use it + dnl for local builds only. + if $CC -Wl,--version 2>&1 | grep -q "GNU ld"; then + GOLD=$($CC -print-prog-name=ld.gold) + case "$GOLD" in + /*) + ;; + *) + GOLD=$(which $GOLD) + ;; + esac + if test -n "$GOLD"; then + mkdir -p $_objdir/build/unix/gold + ln -s "$GOLD" $_objdir/build/unix/gold/ld + if $CC -B $_objdir/build/unix/gold -Wl,--version 2>&1 | grep -q "GNU gold"; then + LDFLAGS="$LDFLAGS -B $_objdir/build/unix/gold" + else + rm -rf $_objdir/build/unix/gold + fi + fi + fi +fi + if test "$GNU_CC"; then CFLAGS="$CFLAGS -ffunction-sections -fdata-sections" CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections -fno-exceptions" diff --git a/js/src/build/autoconf/compiler-opts.m4 b/js/src/build/autoconf/compiler-opts.m4 index f3d6a0d3333..4c56c565a76 100644 --- a/js/src/build/autoconf/compiler-opts.m4 +++ b/js/src/build/autoconf/compiler-opts.m4 @@ -115,6 +115,30 @@ if test -z "$GNU_CC"; then esac fi +if test "$GNU_CC" -a -n "$DEVELOPER_OPTIONS"; then + dnl if the default linker is BFD ld, check if gold is available and try to use it + dnl for local builds only. + if $CC -Wl,--version 2>&1 | grep -q "GNU ld"; then + GOLD=$($CC -print-prog-name=ld.gold) + case "$GOLD" in + /*) + ;; + *) + GOLD=$(which $GOLD) + ;; + esac + if test -n "$GOLD"; then + mkdir -p $_objdir/build/unix/gold + ln -s "$GOLD" $_objdir/build/unix/gold/ld + if $CC -B $_objdir/build/unix/gold -Wl,--version 2>&1 | grep -q "GNU gold"; then + LDFLAGS="$LDFLAGS -B $_objdir/build/unix/gold" + else + rm -rf $_objdir/build/unix/gold + fi + fi + fi +fi + if test "$GNU_CC"; then CFLAGS="$CFLAGS -ffunction-sections -fdata-sections" CXXFLAGS="$CXXFLAGS -ffunction-sections -fdata-sections -fno-exceptions"