Skip to content

Commit 99605a0

Browse files
committed
add whether LinkerFlavor uses lld
1 parent f4b80ca commit 99605a0

File tree

1 file changed

+18
-0
lines changed
  • compiler/rustc_target/src/spec

1 file changed

+18
-0
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,24 @@ impl LinkerFlavor {
349349
pub fn is_gnu(self) -> bool {
350350
matches!(self, LinkerFlavor::Gnu(..))
351351
}
352+
353+
/// Returns whether the flavor uses the `lld` linker.
354+
pub fn uses_lld(self) -> bool {
355+
// Exhaustive match in case new flavors are added in the future.
356+
match self {
357+
LinkerFlavor::Gnu(_, Lld::Yes)
358+
| LinkerFlavor::Darwin(_, Lld::Yes)
359+
| LinkerFlavor::WasmLld(..)
360+
| LinkerFlavor::EmCc
361+
| LinkerFlavor::Msvc(Lld::Yes) => true,
362+
LinkerFlavor::Gnu(..)
363+
| LinkerFlavor::Darwin(..)
364+
| LinkerFlavor::Msvc(_)
365+
| LinkerFlavor::Unix(_)
366+
| LinkerFlavor::Bpf
367+
| LinkerFlavor::Ptx => false,
368+
}
369+
}
352370
}
353371

354372
macro_rules! linker_flavor_cli_impls {

0 commit comments

Comments
 (0)