-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use lld by default on x64 Ubuntu 20.04 LTS #71515
Comments
As a distro maintainer (Fedora and RHEL), I would definitely want this to use the system lld, at least when we're talking about the system rustc that I compile. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There is no such thing as a Ubuntu 20.04 LTS target platform (unlike wasm or the bare embedded targets you mention), but restricting it to |
yes, doing a good job with Ubuntu will likely get a lot of x86_64-unknown-linux-gnu working. but i'd rather get one specific (major) distro working first, since we're talking about integrating with system toolchains here. |
@Gankra I assumed you meant a target based check because the two other cases you mention (wasm and bare metal) are target based. Now I'm even more confused. What do you want to do? A host based check? As in: cargo or rustc trying to invoke |
I don't intend to explicitly check for the distro/release, but rather am willing to have toolchain checks which succeed on vanilla Ubuntu 20.04 but e.g. don't succeed on the latest Arch or older Ubuntus. So we don't need to worry about supporting using rust-lld with older versions of gcc/clang or whatever other tools, as long as our checks are solid enough to detect those things and fall back to using the native The starting point of this would be to not have this detection set up. We would instead blindly try to use rust-lld on x64 linux gnu targets if it's explicitly requested with the In all likelihood this will incidentally get most major modern distro releases working well, but I would regard that as a Happy Accident, and not a priority. It would however provide a tool for distro maintainers to check if rust-lld mode works for them, which is good and useful. After that we would add the detection or expand support until we could have the compiler try to automatically enable rust-lld without an explicit request on x64 linux gnu targets (possibly this step would be done by Cargo and not rustc). Once this is in good enough shape (everything working, not necessarily using rust-lld), we would enable this behaviour in production. From there we will have a solid foundation for folks to push forward rust-lld support on their platforms by either making our toolchain detection more sophisticated, or by updating their distros to meet our requirements. |
@Gankra thanks for the explainer. Have there been any "please test LLD" threads? Those were done e.g. for pipelined compilation and might be helpful in this instance as well. Also maybe one should think about adding an LLD label for issues so that they can be tracked. |
we should have an mvp of #71519 before we ask folks to try out linux lld support |
@1000teslas provided that C libraries have been fixed in #86740, what's the next thing to do to finally use |
@Logarithmus I have no idea to be honest. I was pretty much just following what @Gankra suggested. |
@1000teslas oh wow, great work! All that's left to do is advertise the new flag and provide some instructions for people to test out if it works correctly/and how it performs. I know there was some discussion about the final flag name, could you post instructions on how to use it here? Then someone more familiar with community rallying can encourage people to check it out. |
@Gankra It is used like this: Where should I post the instructions? |
I've prodded the compiler folks to do a writeup, we should be able to take care of the rest for you. I'll post a link the the internals/users thread when it's ready (hopefully very soon, sorry for the slow response on your initial ping). |
Unfortunately, it seems like my PR only works for a stage1 toolchain. I tried to dogfood my PR using a nightly toolchain from rustup on one of my pure-Rust projects and I get some weird errors. When I use ldd on the rust-lld from the nightly toolchain provided by rustup, I see: Then again, I'm using a "weird" distro (NixOS), so maybe it'll work on a more conventional Linux distro. |
|
@bjorn3 Are you saying that even if my system's Anyway, I get errors that look like
|
@1000teslas I'd like to help get the word out about testing this more broadly, would you be able to join us in the compiler team's Zulip so that we can hash out the details? https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Need.20users.2Finternals.20thread.20for.20gcc-lld/near/245177775 |
Visited during T-compiler backlog bonanza. The work that @lqd is doing for rust-lang/compiler-team#510 are meant to be the final steps to unblocking turning lld on by default for Linux. @rustbot label: S-tracking-impl-incomplete |
Now that rust-lang/compiler-team#510 is finished, I believe the next step here is to do some performance investigation to see if it's worth turning this on by default. If anyone would like to chime in with their results of turning this on for their Rust projects, now's the time to share your results. :) |
I just tried this on https://github.com/rust-lang/docs.rs, to get the link time I used
So Footnotes
|
Is it still the case that lld lacks jobserver support? Is that going to be a blocker to turning it on by default? |
We've seen about 40% reduction in build times at SUSE for projects that use LLD over the default system linker. I don't have the full metrics on hand right now however. |
My current project is a pretty typical website backend. Pretty heavy on dependencies: Web server, database pool, templating engine, etc. The build time on my local machine is pretty much cut in half, from two minutes to one minute for a clean build, when I change the linker from the system default (the gnu one I assume) to lld. However, in CI the difference wasn't nearly as dramatic. Possibly due to the version of llvm / lld in CI being several llvm versions behind the one on my local machine. |
For me, this is mostly about development experience. When building a big project incrementally, the time to build is dominated by the linking time. |
There does not appear to be blockers for this per rust-lang/rust#71515.
There does not appear to be blockers for this per rust-lang/rust#71515.
what about |
This comment was marked as resolved.
This comment was marked as resolved.
This issue is purely about a single target (and even a single distro within that target), any other targets would fall under the more general issue linked in the OP or their own tracking issues. |
**What's wrong with `ld`?** It's very slow and uses a lot of memory. **Why `lld`?** It's fast, mature, and well-supported. Meta and Google use it for all their linking workloads. We're already using it for macos and x86-64 Windows. There is [ongoing work to make it the default for rustc](rust-lang/rust#71515), and it already is default on a few platforms. **Why not `mold`?** Mold is generally faster, but the margin is slim enough for our workloads that it doesn't really matter. Mold only recently got support for LTO, doesn't support v0 rust symbol demanging, doesn't support BOLT (though we don't use that yet), etc. Mold is maturing quickly, but `lld` still seems like the "safer" choice.
status update: as of #124129, rustup-distributed rustc (not distros') on |
#8166) **What's wrong with `ld`?** It's very slow and uses a lot of memory. **Why `lld`?** It's fast, mature, and well-supported. Meta and Google use it for all their linking workloads. We're already using it for macos and x86-64 Windows. There is [ongoing work to make it the default for rustc](rust-lang/rust#71515), and it already is default on a few platforms. **Why not `mold`?** Mold is generally faster, but the margin is slim enough for our workloads that it doesn't really matter. Mold only recently got support for LTO, doesn't support v0 rust symbol demanging, doesn't support BOLT (though we don't use that yet), etc. Mold is maturing quickly, but `lld` still seems like the "safer" choice.
Upstream-shipped `rust-ld` is now used as default linker for some targets on nightly. It needs ld-wrapper for interopation with libraries from Nix. Currently `wrapBintools` interface is uneasy for hook use inside a derivation also containing non-bintools stuff. We hereby copy part of the implementation and wrap `rust-ld` in-place. See: rust-lang/rust#71515 (comment)
Upstream-shipped `rust-ld` is now used as default linker for some targets on nightly. It needs ld-wrapper for interopation with libraries from Nix. Currently `wrapBintools` interface is uneasy for hook use inside a derivation also containing non-bintools stuff. We hereby copy part of the implementation and wrap `rust-ld` in-place. See: rust-lang/rust#71515 (comment)
* mk-component-set: apply ld-wrapper for rust-ld Upstream-shipped `rust-ld` is now used as default linker for some targets on nightly. It needs ld-wrapper for interopation with libraries from Nix. Currently `wrapBintools` interface is uneasy for hook use inside a derivation also containing non-bintools stuff. We hereby copy part of the implementation and wrap `rust-ld` in-place. See: rust-lang/rust#71515 (comment) * Bump minimal supported stable nixpkgs to 23.05 We use `env` attrset in `mkDerivation`.
vercel#8166) **What's wrong with `ld`?** It's very slow and uses a lot of memory. **Why `lld`?** It's fast, mature, and well-supported. Meta and Google use it for all their linking workloads. We're already using it for macos and x86-64 Windows. There is [ongoing work to make it the default for rustc](rust-lang/rust#71515), and it already is default on a few platforms. **Why not `mold`?** Mold is generally faster, but the margin is slim enough for our workloads that it doesn't really matter. Mold only recently got support for LTO, doesn't support v0 rust symbol demanging, doesn't support BOLT (though we don't use that yet), etc. Mold is maturing quickly, but `lld` still seems like the "safer" choice.
#65898) Copies changes from vercel/turborepo#8166, and updates contributing documentation to include the installation of lld. > **What's wrong with `ld`?** It's very slow and uses a lot of memory. > > **Why `lld`?** It's fast, mature, and well-supported. Meta and Google use it for all their linking workloads. We're already using it for macos and x86-64 Windows. There is [ongoing work to make it the default for rustc](rust-lang/rust#71515), and it already is default on a few platforms. > > **Why not `mold`?** Mold is generally faster, but the margin is slim enough for our workloads that it doesn't really matter. Mold only recently got support for LTO, doesn't support v0 rust symbol demanging, doesn't support BOLT (though we don't use that yet), etc. Mold is maturing quickly, but `lld` still seems like the "safer" choice.
This is a metabug, constraining the unbound scope of #39915.
What is lld
A linker that's part of the llvm project, which is desirable for two reasons:
Rust currently ships its own copy of lld which it calls rust-lld. This is used by default to link bare-metal targets and wasm.
Goal
The goal of this metabug is to use rust-lld by default on a major x64 linux distro. I have arbitrarily chosen Ubuntu 20.04 LTS as our target. With all likelihood, this will incidentally get it working/enabled on many other linux distros, BSDs, and other similar platforms, but I am purposefully constraining the scope to one distro for the sake of focusing the effort.
My understanding is that the ELF backend is quite well maintained. Quoting lld's own landing page:
Hopefully this has continued to improve, and using lld will be a slam dunk. Although I specify that we should use rust-lld, it may be necessary/desirable to detect and use system copies of lld.
Blocking Issues
The text was updated successfully, but these errors were encountered: