Skip to content

Conversation

Kobzol
Copy link
Member

@Kobzol Kobzol commented Sep 29, 2025

This PR generalizes the previous hardcoded logic for setting self-contained LLD to be used as the default Linker on Linux GNU targets. The changes made:

  1. rust.lld now only controls whether LLD is built and included in the sysroot, nothing else
  2. The linker override for using rust-lld through cc can now be applied to all Linux targets. It is configured through target.<target>.default-linker-linux = "self-contained-lld-cc"
  3. Bootstrap no longer automatically enables LLD for x86_64-unknown-linux-gnu if there is no external LLVM config being used. Instead, this decision now has to be made explicitly, and it has thus moved on our side from bootstrap's code to the CI config of x86_64-unknown-linux-gnu (where it IMO should be). This will also make it trivial to enable it also for other targets (e.g. aarch64-unknown-linux-gnu - this PR will make that change be a one-liner).

Note that in contrast to what I described in #146640, I didn't bother moving rust.lld to llvm.lld. We can do that separately later, but I don't think it's worth the churn. I realized that rust is perhaps a better place for this, because it not only controls whether LLD is built, but also if it is included in the compiler sysroot. So to truly distinguish these two, we'd need both llvm.lld and rust.lld, which doesn't seem worth it. Note that rust.codegen-backends = ["llvm"] works in the same way, it tells bootstrap to build LLVM and include it in the sysroot. So it is consistent with rust.lld

Related to: #146640

r? @jieyouxu

@rustbot
Copy link
Collaborator

rustbot commented Sep 29, 2025

This PR modifies bootstrap.example.toml.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

These commits modify compiler targets.
(See the Target Tier Policy.)

@rustbot rustbot added A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Sep 29, 2025
@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

Choose a reason for hiding this comment

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

This was supposed to be linux_gnu.rs, not linux_musl.rs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, the files are too similar 😆 I actually wanted to put this into linux.rs directly, as the override should also work for MUSL targets. Unless you think we should only allow it for linux-gnu.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, but if we put it into linux.rs, then musl would override link_self_contained: LinkSelfContainedDefault::InferredForMusl, that's not ideal. Ideally we should use the override at the very end of the config, not at the beginning, I guess.

@lqd
Copy link
Member

lqd commented Sep 30, 2025

3. Bootstrap no longer automatically enables LLD for x86_64-unknown-linux-gnu if there is no external LLVM config being used

Do you mean this is disabling the lld default for x64 linux and contributors have to change their local configs to keep it?

@Kobzol
Copy link
Member Author

Kobzol commented Sep 30, 2025

Currently yes. I realize now that this is probably not a good idea, as we want to have as much coverage of LLD as possible.

Then what I would do it configure this to be enabled by default in bootstrap for this specific target (either in code or bootstrap.toml default profiles), and then allow distros to opt-out.

But enabling it by default would require us to also set rust.lld to true, or only override rust-lld when rust.lld is enabled, which is essentially what happened before and what I wanted to get rid off =D

Ok then I would propose:

  • Enable the override by default
  • If rust.lld is unset, enable rust.lld when the override is enabled

Thus essentially the other way around than it was before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants