From 1a643205e3bcddedd897751f559a0b036a04fdf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Fri, 22 Aug 2025 15:43:59 +0000 Subject: [PATCH 1/2] adjust tests to leave lld in beta - stable tests to ensure lld is not used - splitting beta (where lld is on) behavior from stable (where it is off) --- tests/run-make/rust-lld-by-default-stable/main.rs | 1 + tests/run-make/rust-lld-by-default-stable/rmake.rs | 13 +++++++++++++ .../rust-lld-x86_64-unknown-linux-gnu-dist/rmake.rs | 5 +++-- .../rust-lld-x86_64-unknown-linux-gnu/rmake.rs | 5 +++-- 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 tests/run-make/rust-lld-by-default-stable/main.rs create mode 100644 tests/run-make/rust-lld-by-default-stable/rmake.rs diff --git a/tests/run-make/rust-lld-by-default-stable/main.rs b/tests/run-make/rust-lld-by-default-stable/main.rs new file mode 100644 index 0000000000000..f328e4d9d04c3 --- /dev/null +++ b/tests/run-make/rust-lld-by-default-stable/main.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/tests/run-make/rust-lld-by-default-stable/rmake.rs b/tests/run-make/rust-lld-by-default-stable/rmake.rs new file mode 100644 index 0000000000000..c8ee8c42f65a8 --- /dev/null +++ b/tests/run-make/rust-lld-by-default-stable/rmake.rs @@ -0,0 +1,13 @@ +// Ensure that rust-lld is *not* used as the default linker on `x86_64-unknown-linux-gnu` on stable. + +//@ only-stable +//@ only-x86_64-unknown-linux-gnu + +use run_make_support::linker::assert_rustc_doesnt_use_lld; +use run_make_support::rustc; + +fn main() { + // A regular compilation should not use rust-lld by default. We'll check that by asking the + // linker to display its version number with a link-arg. + assert_rustc_doesnt_use_lld(rustc().input("main.rs")); +} diff --git a/tests/run-make/rust-lld-x86_64-unknown-linux-gnu-dist/rmake.rs b/tests/run-make/rust-lld-x86_64-unknown-linux-gnu-dist/rmake.rs index c315d36a39d7c..f912588176bc1 100644 --- a/tests/run-make/rust-lld-x86_64-unknown-linux-gnu-dist/rmake.rs +++ b/tests/run-make/rust-lld-x86_64-unknown-linux-gnu-dist/rmake.rs @@ -1,7 +1,8 @@ -// Ensure that rust-lld is used as the default linker on `x86_64-unknown-linux-gnu` -// dist artifacts and that it can also be turned off with a CLI flag. +// Ensure that rust-lld is used as the default linker on `x86_64-unknown-linux-gnu` dist artifacts +// (except on stable) and that it can also be turned off with a CLI flag. //@ only-dist +//@ ignore-stable //@ only-x86_64-unknown-linux-gnu use run_make_support::linker::{assert_rustc_doesnt_use_lld, assert_rustc_uses_lld}; diff --git a/tests/run-make/rust-lld-x86_64-unknown-linux-gnu/rmake.rs b/tests/run-make/rust-lld-x86_64-unknown-linux-gnu/rmake.rs index 00415d27aaf33..f2825d12e0c8d 100644 --- a/tests/run-make/rust-lld-x86_64-unknown-linux-gnu/rmake.rs +++ b/tests/run-make/rust-lld-x86_64-unknown-linux-gnu/rmake.rs @@ -1,11 +1,12 @@ -// Ensure that rust-lld is used as the default linker on `x86_64-unknown-linux-gnu` -// and that it can also be turned off with a CLI flag. +// Ensure that rust-lld is used as the default linker on `x86_64-unknown-linux-gnu` (except on +// stable) and that it can also be turned off with a CLI flag. // // This version of the test checks that LLD is used by default when LLD is enabled in the // toolchain. There is a separate test that checks that LLD is used for dist artifacts // unconditionally. //@ needs-rust-lld +//@ ignore-stable //@ only-x86_64-unknown-linux-gnu use run_make_support::linker::{assert_rustc_doesnt_use_lld, assert_rustc_uses_lld}; From e38de11e9362f212e9ed32deb67746ea512e90ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Rakic?= Date: Fri, 22 Aug 2025 15:45:34 +0000 Subject: [PATCH 2/2] make bootstrap disable lld on stable --- src/bootstrap/src/core/build_steps/compile.rs | 2 +- src/bootstrap/src/core/config/toml/rust.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 59541bf12def0..dcf083e73fc6e 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1360,7 +1360,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS } // Enable rustc's env var for `rust-lld` when requested. - if builder.config.lld_enabled { + if builder.config.lld_enabled && builder.config.channel != "stable" { cargo.env("CFG_USE_SELF_CONTAINED_LINKER", "1"); } diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index 03da993a17dd2..e93421eb459c0 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -657,6 +657,7 @@ impl Config { // when the config sets `rust.lld = false` if default_lld_opt_in_targets().contains(&self.host_target.triple.to_string()) && self.hosts == [self.host_target] + && self.channel != "stable" { let no_llvm_config = self .target_config