Commit a10729f0 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

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
parent 03009aa7
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment