[commit: ghc] master: configure: Make sure we try all possible linkers (a10729f)
git at git.haskell.org
git at git.haskell.org
Wed Sep 27 21:38:34 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/a10729f028d7175980d9f65e22c9bb9a933461c2/ghc
>---------------------------------------------------------------
commit a10729f028d7175980d9f65e22c9bb9a933461c2
Author: Ben Gamari <bgamari.foss at gmail.com>
Date: Wed Sep 27 15:30:18 2017 -0400
configure: Make sure we try all possible linkers
Previously if we had both ld.lld and ld.gold installed but a gcc which
didn't support -fuse-ld=lld we would fail when trying ld.lld and fall
immediately back to plain ld. Now we will try ld.gold as well. This was
brought to light by #14280, where using ld.bfd resulted in a broken
stage2 compiler.
Test Plan: Configure
Reviewers: angerman, hvr, austin
Reviewed By: angerman
Subscribers: rwbarton, thomie, erikd
GHC Trac Issues: #14280
Differential Revision: https://phabricator.haskell.org/D4038
>---------------------------------------------------------------
a10729f028d7175980d9f65e22c9bb9a933461c2
aclocal.m4 | 59 +++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 41 insertions(+), 18 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index 5425408..fb61e8d 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -2331,28 +2331,51 @@ AC_DEFUN([FIND_LD],[
[],
[enable_ld_override=yes])
- if test "x$enable_ld_override" = "xyes"; then
- TmpLd="$LD" # In case the user set LD
- AC_CHECK_TARGET_TOOLS([TmpLd], [ld.lld ld.gold ld])
-
- out=`$TmpLd --version`
- 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) ;;
- *) AC_MSG_NOTICE([unknown linker version $out]) ;;
- esac
- if test "z$$2" = "z"; then
- AC_MSG_NOTICE([unable to convince '$CC' to use linker '$TmpLd'])
+ find_ld() {
+ # Make sure the user didn't specify LD manually.
+ if test "z$LD" != "z"; then
AC_CHECK_TARGET_TOOL([LD], [ld])
- else
- LD="$TmpLd"
+ return
fi
- else
+
+ # Manually iterate over possible names since we want to ensure that, e.g.,
+ # if ld.lld is installed but gcc doesn't support -fuse-ld=lld, that we
+ # then still try ld.gold and -fuse-ld=gold.
+ for possible_ld in ld.lld ld.gold ld; do
+ TmpLd="" # In case the user set LD
+ AC_CHECK_TARGET_TOOL([TmpLd], [$possible_ld])
+ if test "x$TmpLd" = "x"; then continue; fi
+
+ out=`$TmpLd --version`
+ 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) ;;
+ *) AC_MSG_NOTICE([unknown linker version $out]) ;;
+ esac
+ if test "z$$2" = "z"; then
+ AC_MSG_NOTICE([unable to convince '$CC' to use linker '$TmpLd'])
+ # a terrible hack to prevent autoconf from caching the previous
+ # AC_CHECK_TARGET_TOOL result since next time we'll be looking
+ # for another ld variant.
+ $as_unset ac_cv_prog_ac_ct_TmpLd
+ else
+ LD="$TmpLd"
+ return
+ fi
+ done
+
+ # Fallback
AC_CHECK_TARGET_TOOL([LD], [ld])
- fi
+ }
+
+ if test "x$enable_ld_override" = "xyes"; then
+ find_ld
+ else
+ AC_CHECK_TARGET_TOOL([LD], [ld])
+ fi
- CHECK_LD_COPY_BUG([$1])
+ CHECK_LD_COPY_BUG([$1])
])
# LocalWords: fi
More information about the ghc-commits
mailing list