Skip to content

Commit 1978bc2

Browse files
committed
use env var to enable self-contained linker
1 parent 185b91f commit 1978bc2

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ pub fn target() -> Target {
1818
| SanitizerSet::THREAD;
1919
base.supports_xray = true;
2020

21-
#[cfg(use_rust_lld)]
22-
{
23-
// When we're asked to use the `rust-lld` linker by default, set the appropriate lld-using
24-
// linker flavor, and self-contained linker component.
21+
// When we're asked to use the `rust-lld` linker by default, set the appropriate lld-using
22+
// linker flavor, and self-contained linker component.
23+
if option_env!("CFG_USE_SELF_CONTAINED_LINKER").is_some() {
2524
base.linker_flavor = LinkerFlavor::Gnu(Cc::Yes, Lld::Yes);
2625
base.link_self_contained = crate::spec::LinkSelfContainedDefault::with_linker();
2726
}

src/bootstrap/src/core/build_steps/compile.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1129,10 +1129,9 @@ pub fn rustc_cargo_env(
11291129
cargo.env("CFG_DEFAULT_LINKER", s);
11301130
}
11311131

1132-
// Enable rustc's cfgs for `rust-lld` when requested.
1132+
// Enable rustc's env var for `rust-lld` when requested.
11331133
if builder.config.lld_enabled {
1134-
cargo.rustflag("--cfg=use_rust_lld");
1135-
cargo.rustdocflag("--cfg=use_rust_lld");
1134+
cargo.env("CFG_USE_SELF_CONTAINED_LINKER", "1");
11361135
}
11371136

11381137
if builder.config.rust_verify_llvm_ir {

0 commit comments

Comments
 (0)