Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[CSL-1002] Add lld linker for macOS #244

Closed
wants to merge 1 commit into from
Closed

Conversation

chshersh
Copy link
Contributor

This commit is a part of CSL-1002 issues: speeding up linking to build project faster. gold linker is already added. Though there're some problems with adding lld. Waiting for @neongreen and @nh2 to comment.

@mention-bot
Copy link

@chshersh, thanks for your PR! By analyzing the history of the files in this pull request, we identified @neongreen, @flyingleafe and @volhovm to be potential reviewers.

if os(linux)
ghc-options: -optl-fuse-ld=gold
ld-options: -fuse-ld=gold
if os(darwin)
ghc-options: "-pgmc clang" "-pgma clang" "-pgml clang" "-optl-fuse-ld=lld"
ld-options: -fuse-ld=lld
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using lld in macOS because it doesn't have gold?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also because it's actually faster than gold.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think lld is in a state where can be used on Mach-O, see my comment.
Also, it's not necessarily faster than gold. In many tests we run it goes from parity to 2x faster (in particular scenarios, e.g. when linking with debuginfo or with some options (e.g. -gdb-index). It's a safe claim to say that's generally at least as fast as gold.

Copy link
Contributor

@gromakovsky gromakovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's approved, but as we know it doesn't work. Now everybody can merge it and I am afraid that somebody will do it, so I am rejecting it just in case.

@deepfire
Copy link
Contributor

What is the status of this, @gromakovsky? We need to know if this can be used to speed up Hydra builds.

@gromakovsky
Copy link
Contributor

@deepfire we are already using gold for linux builds (in master). We are not using lld for MacOS because it doesn't work (that's the reason this PR is still open). Niklas can help us with it if it's a priority.

@neongreen
Copy link
Contributor

Looks like we won't need it after switching to GHC 8.2:

 * GHC now tries to use the gold and lld linkers by default. These
   linkers are significantly faster than the BFD linker implementation
   that most Linux distributions use by default. If gold or lld are not
   available GHC will use the system's default linker. GHC can be forced
   to use the default linker by passing --disable-ld-override to
   configure.

@domenkozar
Copy link
Contributor

Afaik this one depends on NixOS/nixpkgs#24744

@dcci
Copy link

dcci commented Aug 22, 2017

LLVM/lld dev here. My $0.02 here.
I'm afraid there's a little of misunderstanding probably derived from the original scope of this project.
Originally, lld was an unified linker for Mach-O/COFF/ELF. This experiment was thrown away and now there are three separate backends (i.e. one for each target).

The MachO backend hasn't been pretty much touched since the split. All the timings for haskell, as far as I can tell have been taken on ELF. I'll be very surprised if the Mach-O backend links anything larger than an hello world (I'm pretty sure it doesn't self-host, because I tried myself). As such, I think having lld has a viable alternative on Nix (MacOS) would require a substantial amount of work and it's definitely not ready for production.

Copy link

@dcci dcci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a good move :)

if os(linux)
ghc-options: -optl-fuse-ld=gold
ld-options: -fuse-ld=gold
if os(darwin)
ghc-options: "-pgmc clang" "-pgma clang" "-pgml clang" "-optl-fuse-ld=lld"
ld-options: -fuse-ld=lld
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think lld is in a state where can be used on Mach-O, see my comment.
Also, it's not necessarily faster than gold. In many tests we run it goes from parity to 2x faster (in particular scenarios, e.g. when linking with debuginfo or with some options (e.g. -gdb-index). It's a safe claim to say that's generally at least as fast as gold.

@dcci
Copy link

dcci commented Aug 22, 2017

Oops, sorry, I thought this was for NixOS. Ignore my comment (although my reasoning is still valid :)

@domenkozar domenkozar closed this Aug 22, 2017
@gromakovsky gromakovsky deleted the build/csl1002-lld branch November 3, 2017 14:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants