Skip to content

Commit 1282d20

Browse files
committed
bootstrap: introduce rust-lld cfg for rustc
This is used to notify we want to use rust-lld as the default linker in a target.
1 parent 0e15f5e commit 1282d20

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,12 @@ pub fn rustc_cargo_env(
11291129
cargo.env("CFG_DEFAULT_LINKER", s);
11301130
}
11311131

1132+
// Enable rustc's cfgs for `rust-lld` when requested.
1133+
if builder.config.lld_enabled {
1134+
cargo.rustflag("--cfg=use_rust_lld");
1135+
cargo.rustdocflag("--cfg=use_rust_lld");
1136+
}
1137+
11321138
if builder.config.rust_verify_llvm_ir {
11331139
cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
11341140
}

src/bootstrap/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
114114
// Needed to avoid the need to copy windows.lib into the sysroot.
115115
(Some(Mode::Rustc), "windows_raw_dylib", None),
116116
(Some(Mode::ToolRustc), "windows_raw_dylib", None),
117+
// If rustc wants to use rust-lld as the default linker in a target spec.
118+
(Some(Mode::Rustc), "use_rust_lld", None),
119+
(Some(Mode::ToolRustc), "use_rust_lld", None),
120+
(Some(Mode::Codegen), "use_rust_lld", None),
117121
];
118122

119123
/// A structure representing a Rust compiler.

0 commit comments

Comments
 (0)