Fix lld detection if both gold and lld are found
ClosedPublic

Authored by tuncer on Jul 26 2017, 9:07 AM.

Details

Summary

If you have ld.gold and ld.lld, then ld.gold will be selected by the
detection logic. This patch prioritizes lld by changing the order. The
rationale for checking lld first is that it's (right now) not part of,
say, a default Linux distro installation and if it's available, it's
very likely that it was installed explicitly and should be seen as a
sign of preference. On FreeBSD LLVM is the (default) base toolchain and
the changed order makes sense there as well, since ld.gold can be
available in /usr/local via ports/pkg. I don't have access to macOS and
can't say anything about their LLVM toolchain.

At some point we could add a check for LD=ld.lld or LD=ld.gold as an
optional override to explicitly select a linker.

Since I cannot really remove gcc on Linux, this was the only way to
configure GHC to use ld.lld.

tuncer created this revision.Jul 26 2017, 9:07 AM

I would love to see this in 8.2.2. That's why I based my local branch on origin/ghc-8.2.

bgamari edited edge metadata.Jul 26 2017, 10:43 AM

I don't really mind changing the order here, but it seems like the user should be explicit in the configure command line (using LD=) if

At some point we could add a check for LD=ld.lld or LD=ld.gold as an optional override to explicitly select a linker.

Indeed this worked in an earlier version of the patch, but it looks like this broke in the fix to Trac #13541.

bgamari accepted this revision.Jul 28 2017, 10:48 AM

Alright, this is fine with me. I'll try to fix the LD option.

This revision is now accepted and ready to land.Jul 28 2017, 10:48 AM
This revision was automatically updated to reflect the committed changes.

LD was fixed in b0d0291085a81e0c192e3e95e66ff078c28e1956. This was merged to ghc-8.2.