[commit: ghc] ghc-8.4: Don't use ld.gold when building libraries for GHCi (b4e3278)

git at git.haskell.org git at git.haskell.org
Fri Feb 23 16:37:51 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.4
Link       : http://ghc.haskell.org/trac/ghc/changeset/b4e32780a976193208eebbddf789eeb80351ac95/ghc

>---------------------------------------------------------------

commit b4e32780a976193208eebbddf789eeb80351ac95
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Wed Feb 21 14:16:00 2018 +0000

    Don't use ld.gold when building libraries for GHCi
    
    Summary:
    ld.gold is buggy when using -r and a linker script.  See upstream bug
    https://sourceware.org/bugzilla/show_bug.cgi?id=22266
    
    This has been causing various brokenness for the GHC runtime linker,
    where we load these broken object files.
    
    Test Plan: Test program from #14675
    
    Reviewers: bgamari, RyanGlScott, alpmestan, hvr, erikd
    
    Subscribers: rwbarton, thomie, erikd, carter
    
    GHC Trac Issues: #14328, #14675, #14291
    
    Differential Revision: https://phabricator.haskell.org/D4431
    
    (cherry picked from commit 0a3629af36e89de73b7012c726fd533c4c5460fb)


>---------------------------------------------------------------

b4e32780a976193208eebbddf789eeb80351ac95
 aclocal.m4                 | 13 ++++++++++---
 configure.ac               |  2 ++
 mk/config.mk.in            |  1 +
 rules/build-package-way.mk |  7 +++++--
 4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index 99ff1bf..cf93474 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -2355,6 +2355,7 @@ AC_DEFUN([FIND_LD],[
         # Make sure the user didn't specify LD manually.
         if test "z$LD" != "z"; then
             AC_CHECK_TARGET_TOOL([LD], [ld])
+            LD_NO_GOLD=$LD
             return
         fi
 
@@ -2367,10 +2368,16 @@ AC_DEFUN([FIND_LD],[
             if test "x$TmpLd" = "x"; then continue; fi
 
             out=`$TmpLd --version`
+            LD_NO_GOLD=$TmpLd
             case $out in
-              "GNU ld"*)   FP_CC_LINKER_FLAG_TRY(bfd, $2) ;;
-              "GNU gold"*) FP_CC_LINKER_FLAG_TRY(gold, $2) ;;
-              "LLD"*)      FP_CC_LINKER_FLAG_TRY(lld, $2) ;;
+              "GNU ld"*)
+                   FP_CC_LINKER_FLAG_TRY(bfd, $2) ;;
+              "GNU gold"*)
+                   FP_CC_LINKER_FLAG_TRY(gold, $2)
+                   LD_NO_GOLD=ld
+                   ;;
+              "LLD"*)
+                   FP_CC_LINKER_FLAG_TRY(lld, $2) ;;
               *) AC_MSG_NOTICE([unknown linker version $out]) ;;
             esac
             if test "z$$2" = "z"; then
diff --git a/configure.ac b/configure.ac
index ec96d2c..57d76b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -544,8 +544,10 @@ FIND_LD([$target],[GccUseLdOpt])
 CONF_GCC_LINKER_OPTS_STAGE1="$CONF_GCC_LINKER_OPTS_STAGE1 $GccUseLdOpt"
 CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2 $GccUseLdOpt"
 LdCmd="$LD"
+LdNoGoldCmd="$LD_NO_GOLD"
 CFLAGS="$CFLAGS $GccUseLdOpt"
 AC_SUBST([LdCmd])
+AC_SUBST([LdNoGoldCmd])
 
 FP_PROG_LD_IS_GNU
 FP_PROG_LD_BUILD_ID
diff --git a/mk/config.mk.in b/mk/config.mk.in
index 86c626d..e5ec04a 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -727,6 +727,7 @@ HaveDtrace		= @HaveDtrace@
 USE_DTRACE = $(HaveDtrace)
 DTRACE			= @DtraceCmd@
 
+LD_NO_GOLD = @LdNoGoldCmd@
 LD = @LdCmd@
 NM = @NmCmd@
 AR = @ArCmd@
diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk
index 9c101c4..8d14b7a 100644
--- a/rules/build-package-way.mk
+++ b/rules/build-package-way.mk
@@ -121,8 +121,11 @@ BINDIST_LIBS += $$($1_$2_GHCI_LIB)
 endif
 endif
 $$($1_$2_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) $$($1_$2_LD_SCRIPT)
-	$$(call cmd,LD) $$(CONF_LD_LINKER_OPTS_STAGE$4) -r $$(if $$($1_$2_LD_SCRIPT),$$($1_$2_LD_SCRIPT_CMD) $$($1_$2_LD_SCRIPT)) -o $$@ $$(EXTRA_LD_LINKER_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS)
-
+	$$(call cmd,LD_NO_GOLD) $$(CONF_LD_LINKER_OPTS_STAGE$4) -r $$(if $$($1_$2_LD_SCRIPT),$$($1_$2_LD_SCRIPT_CMD) $$($1_$2_LD_SCRIPT)) -o $$@ $$(EXTRA_LD_LINKER_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS)
+# NB. LD_NO_GOLD above: see #14328 (symptoms: #14675,#14291). At least
+# some versions of ld.gold appear to have a bug that causes the
+# generated GHCi library to have some bogus relocations. Performance
+# isn't critical here, so we fall back to the ordinary ld.
 ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES"
 # Don't bother making ghci libs for bootstrapping packages
 ifneq "$4" "0"



More information about the ghc-commits mailing list