Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider lld as linker on ELF (Linux) #27951

Closed
dcci opened this issue Aug 5, 2017 · 12 comments
Closed

Consider lld as linker on ELF (Linux) #27951

dcci opened this issue Aug 5, 2017 · 12 comments
Labels
6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related

Comments

@dcci
Copy link

dcci commented Aug 5, 2017

Issue description

lld (http://lld.llvm.org/) seems to be "mature enough", these days.
With 5.0 release, it might make sense giving a shot as it's much much faster than ld.bfd (which is still the default on every Linux as far as I can tell) and reasonably faster than ld.gold.
ghc recently tried it with reasonable success
https://www.reddit.com/r/haskell/comments/63y43y/liked_linking_3x_faster_with_gold_link_10x_faster/

I'll be happy to work on this (as I also work on lld/llvm) but first I want to know if it's something reasonable (& probably I'll need some guidance on how to actually implement/try this).

@copumpkin
Copy link
Member

This (and more LLVM-based tools in general) might also make cross-compilation more pleasant, cc @Ericson2314

I'd also love to see lld for Mach-O files on Darwin but it's less clear to me how mature it is in that space. We already use LLVM for everything else there, so it wouldn't be too far off.

@fpletz fpletz added this to the 18.03 milestone Aug 7, 2017
@domenkozar
Copy link
Member

Duplicates #24744

@copumpkin
Copy link
Member

Not quite a dupe, as that one wants lld to work properly, and this one wants it (as I understand it) in the stdenv as the default linker.

@dcci
Copy link
Author

dcci commented Aug 9, 2017

@domenkozar I don't think it's a dupe.
@copumpkin I'm afraid having lld for Mach-O is still a pipe dream as that bit of the linker is quite unmaintained (last I tried, ~ 1 month ago, lld on Mach-O wasn't even able to self-host with a recent'(ish) OS/toolchain [El Capitan]).

Assuming there's consensus to go forward, I'd love to discuss next steps.
I'm not a NixOS dev, but given I use it on my main workstation these days (and I love it :)) I thought I could help a bit on this side. What's the best way to do this work incrementally?
I'm very willing to debug any mislinks/crashes etc..

Something else I'd like to add.
lld/ELF is quite unique as it has LTO support built-in (differently from ld.gold and ld.bfd which need a plugin to work). As LLVM developer I found out this being a killer feature as you just need to pass -flto to clang and lld can read LLVM bitcode files and call the mover/optimizer transparently.
This has the great advantage that, if NixOS decides to support LTO at some point in the future, enabling it it's just a matter of passing a flag to clang (well, two, if you consider -fuse-ld=lld) instead of building an extra shared library and making sure the plugin bits are passed down to the linker (which may be not particularly pleasant in more complex build systems).

@Ericson2314 Ericson2314 added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Aug 16, 2017
@vcunat vcunat removed this from the 18.03 milestone Mar 4, 2018
@nh2
Copy link
Contributor

nh2 commented Mar 11, 2019

@dcci Would you be up for working on #24744, which is a requirement for making this happen?

It would be great to have good lld support across nixpkgs.

@stale
Copy link

stale bot commented Jun 3, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 3, 2020
@Gaelan
Copy link
Contributor

Gaelan commented Dec 28, 2020

Still important to me.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 28, 2020
@S-NA
Copy link
Contributor

S-NA commented Jan 19, 2021

In 2020 a new Mach-O backend was added. According to the homepage, "[t]he linker supports ELF (Unix), PE/COFF (Windows), Mach-O (macOS) and WebAssembly in descending order of completeness." While I cannot personally attest to it, I have heard good reports of people being able to use LLD for Mach-O. That being said the new hurdle is with Apple moving to AArch64 and requiring that executable binaries be code signed on the new macOS machines. (Which the system linker (ld64) does by default.)

@stale
Copy link

stale bot commented Jul 19, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 19, 2021
@nh2
Copy link
Contributor

nh2 commented Jul 20, 2021

As relevant as ever.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 20, 2021
@stale
Copy link

stale bot commented May 1, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label May 1, 2022
@Ericson2314
Copy link
Member

This can be done using the linker field of the platform config, which is also set by useLLVM = true and pkgsLLVM. I think we are done here!

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label May 1, 2022
@rrbutani rrbutani added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related
Projects
None yet
Development

No branches or pull requests

10 participants