Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/config/toml/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/run-make/rust-lld-by-default-stable/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
13 changes: 13 additions & 0 deletions tests/run-make/rust-lld-by-default-stable/rmake.rs
Original file line number Diff line number Diff line change
@@ -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"));
}
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
5 changes: 3 additions & 2 deletions tests/run-make/rust-lld-x86_64-unknown-linux-gnu/rmake.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
Loading