Skip to content

Conversation

Kobzol
Copy link
Member

@Kobzol Kobzol commented Oct 13, 2025

Reopen of #147157, because apparently bors can't deal with it for some reason.


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. If rust.lld is set to false, it will disable the default opt into LLD on x64 Linux.
  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-override = "self-contained-lld-cc"/"off"

Here is how it behaves:

  1. If you don't set any options, x64 Linux will default into default-linker-linux-override = "self-contained-lld-cc" and also rust.lld = true.
  2. If you set rust.lld = false, you disable this override
  3. If you set target.x86_64-unknown-linux-gnu.default-linux-linker-override = "off", you disable this override
  4. If you set target.x86_64-unknown-linux-gnu.llvm-config = ..., you disable this override

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? @ghost

@rustbot
Copy link
Collaborator

rustbot commented Oct 13, 2025

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

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

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

This PR modifies bootstrap.example.toml.

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

@rustbot rustbot added 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. labels Oct 13, 2025
@Kobzol
Copy link
Member Author

Kobzol commented Oct 13, 2025

@bors r=jieyouxu

@bors
Copy link
Collaborator

bors commented Oct 13, 2025

📌 Commit da86710 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 13, 2025
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Oct 13, 2025
Generalize configuring LLD as the default linker in bootstrap

Reopen of rust-lang#147157, because apparently bors can't deal with it for some reason.

r? `@ghost`
@Zalathar
Copy link
Contributor

I copy-pasted the description from the old PR, because that sort of thing tends to be handy when looking through history.

@Zalathar
Copy link
Contributor

The old PR was rollup=never; should this one be too?

@Kobzol
Copy link
Member Author

Kobzol commented Oct 13, 2025

Bors still haven't updated the mergeability status even of this PR.. let's just try to roll it up and see what happens. It might be the only way to merge this, lol.

@jieyouxu
Copy link
Member

Do we need to attempt a resync?

@Kobzol
Copy link
Member Author

Kobzol commented Oct 13, 2025

It caught up to this PR now, so I don't think so. #147569 is the only approved one right now that doesn't have the mergeability status.

bors added a commit that referenced this pull request Oct 13, 2025
Rollup of 6 pull requests

Successful merges:

 - #147514 (repr_transparent_external_private_fields: normalize types during traversal)
 - #147605 (Add doc links between `{integer}::from_str_radix` and `from_str`)
 - #147608 (cg_llvm: Use `LLVMDIBuilderCreateGlobalVariableExpression`)
 - #147623 (Clear `ChunkedBitSet` without reallocating)
 - #147625 (Add a warning when running tests with the GCC backend and debug assertions are enabled)
 - #147626 (Generalize configuring LLD as the default linker in bootstrap)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0e6ec72 into rust-lang:master Oct 13, 2025
21 of 30 checks passed
rust-timer added a commit that referenced this pull request Oct 13, 2025
Rollup merge of #147626 - Kobzol:lld-generalize2, r=jieyouxu

Generalize configuring LLD as the default linker in bootstrap

Reopen of #147157, because apparently bors can't deal with it for some reason.

r? ``@ghost``
@rustbot rustbot added this to the 1.92.0 milestone Oct 13, 2025
@Kobzol Kobzol deleted the lld-generalize2 branch October 13, 2025 16:56
@weihanglo
Copy link
Member

#147569 is the only approved one right now that doesn't have the mergeability status.

What does that mean? Will bors pick up #147569 even if the mergeable status is missing?

@Kobzol
Copy link
Member Author

Kobzol commented Oct 13, 2025

You're asking questions no one knows the answer to 😆 If it gets stuck at the top of the queue, I'd consider closing that PR and reopening it again.

@weihanglo
Copy link
Member

bors is working on it 😆
#147569 (comment)

@dpaoliello
Copy link
Contributor

FYI, we started to see failures with our internal Arm64EC validation pipeline after this PR was merged:

  • Previously we weren't building lld, but after this change we started to. We don't set rust.lld so I would have assumed that it would be disabled.
  • The lld build doesn't use the same flags set for the LLVM build, so it was failing to link as Arm64EC since it was missing:
    if target.starts_with("arm64ec") {
    // MSVC linker requires the -machine:arm64ec flag to be passed to
    // know it's linking as Arm64EC (vs Arm64X).
    ldflags.exe.push(" -machine:arm64ec");
    ldflags.shared.push(" -machine:arm64ec");

For context, this is how we are configuring and running the build (via an Arm64 VS PowerShell):

      &python .\src\bootstrap\configure.py `
        --set 'build.build-dir=build.stage0' `
        --set 'build.submodules=false' `
        --set 'llvm.download-ci-llvm=false' `
        --set 'llvm.targets=AArch64' `
        --set 'llvm.experimental-targets=' `
        --set 'llvm.link-jobs=8'
      if (!$?) { exit $LASTEXITCODE }

      &python .\x.py build `
        --stage 2 `
        --build aarch64-pc-windows-msvc `
        --host arm64ec-pc-windows-msvc `
        --target arm64ec-pc-windows-msvc `
        compiler cargo library/std rustfmt clippy rustdoc
      if (!$?) { exit $LASTEXITCODE }

@Kobzol
Copy link
Member Author

Kobzol commented Oct 14, 2025

Could you please share your whole bootstrap.toml?

@dpaoliello
Copy link
Contributor

We don't have a checked-in bootstrap.toml, we just run configure and use that.

@Kobzol
Copy link
Member Author

Kobzol commented Oct 14, 2025

Ah, crap, I see the problem. LLD is enabled globally, but the override is configured per target. So if at least a single target opts into LLD, then rust.lld will be set to true. That's annoying, ugh. I'll try to figure something out.

@Kobzol
Copy link
Member Author

Kobzol commented Oct 14, 2025

Opened #147698.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants