[commit: ghc] ghc-8.2: configure: Make sure we try all possible linkers (5bce35c)
git at git.haskell.org
git at git.haskell.org
Mon Oct 2 11:27:28 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.2
Link : http://ghc.haskell.org/trac/ghc/changeset/5bce35caf1767b65fce32ca55b7036fbd0d546f7/ghc
>---------------------------------------------------------------
commit 5bce35caf1767b65fce32ca55b7036fbd0d546f7
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
(cherry picked from commit a10729f028d7175980d9f65e22c9bb9a933461c2)
>---------------------------------------------------------------
5bce35caf1767b65fce32ca55b7036fbd0d546f7
aclocal.m4 | 59 +++++++++++++++++++++++++++++++++++++++++------------------
1 file changed, 41 insertions(+), 18 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index 516584b..d5078de 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -2340,28 +2340,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