diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-09-27 15:30:18 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-09-27 17:37:29 -0400 |
commit | a10729f028d7175980d9f65e22c9bb9a933461c2 (patch) | |
tree | 00b2c855e0adf55d2c9a2a7589c0f64d013b4a2b /aclocal.m4 | |
parent | 03009aa70a099867331afb9876333c687454c5d5 (diff) | |
download | haskell-a10729f028d7175980d9f65e22c9bb9a933461c2.tar.gz |
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
Diffstat (limited to 'aclocal.m4')
-rw-r--r-- | aclocal.m4 | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/aclocal.m4 b/aclocal.m4 index 5425408c88..fb61e8d32e 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 |