Skip to content

Commit

Permalink
use env var to enable self-contained linker
Browse files Browse the repository at this point in the history
  • Loading branch information
lqd committed Apr 20, 2024
1 parent 185b91f commit 1978bc2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ pub fn target() -> Target {
| SanitizerSet::THREAD;
base.supports_xray = true;

#[cfg(use_rust_lld)]
{
// When we're asked to use the `rust-lld` linker by default, set the appropriate lld-using
// linker flavor, and self-contained linker component.
// When we're asked to use the `rust-lld` linker by default, set the appropriate lld-using
// linker flavor, and self-contained linker component.
if option_env!("CFG_USE_SELF_CONTAINED_LINKER").is_some() {
base.linker_flavor = LinkerFlavor::Gnu(Cc::Yes, Lld::Yes);
base.link_self_contained = crate::spec::LinkSelfContainedDefault::with_linker();
}
Expand Down
5 changes: 2 additions & 3 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,10 +1129,9 @@ pub fn rustc_cargo_env(
cargo.env("CFG_DEFAULT_LINKER", s);
}

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

if builder.config.rust_verify_llvm_ir {
Expand Down

0 comments on commit 1978bc2

Please sign in to comment.