Skip to content

Commit 5ad7a10

Browse files
committed
enable rust-lld on x86_64-unknown-linux-gnu when requested
the `rust.lld` config enables rustc's `#[cfg(use_rust_lld)]`, and we: - set the linker-flavor to use lld - enable the self-contained linker this makes the target use the rust-lld linker by default
1 parent ed3c115 commit 5ad7a10

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

compiler/rustc_target/src/spec/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,12 @@ impl LinkSelfContainedDefault {
625625
_ => "crt-objects-fallback",
626626
}
627627
}
628+
629+
/// Creates a `LinkSelfContainedDefault` enabling the self-contained linker for target specs
630+
/// (the equivalent of `-Clink-self-contained=+linker` on the CLI).
631+
pub fn with_linker() -> LinkSelfContainedDefault {
632+
LinkSelfContainedDefault::WithComponents(LinkSelfContainedComponents::LINKER)
633+
}
628634
}
629635

630636
bitflags::bitflags! {

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

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ 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.
25+
base.linker_flavor = LinkerFlavor::Gnu(Cc::Yes, Lld::Yes);
26+
base.link_self_contained = crate::spec::LinkSelfContainedDefault::with_linker();
27+
}
28+
2129
Target {
2230
llvm_target: "x86_64-unknown-linux-gnu".into(),
2331
metadata: crate::spec::TargetMetadata {

0 commit comments

Comments
 (0)