Skip to content

Commit 5ea0f63

Browse files
committed
add whether LinkerFlavor invokes the linker via a C/C++ compiler
1 parent 99605a0 commit 5ea0f63

File tree

1 file changed

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

1 file changed

+19
-0
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,25 @@ impl LinkerFlavor {
367367
| LinkerFlavor::Ptx => false,
368368
}
369369
}
370+
371+
/// Returns whether the flavor calls the linker via a C/C++ compiler.
372+
pub fn uses_cc(self) -> bool {
373+
// Exhaustive match in case new flavors are added in the future.
374+
match self {
375+
LinkerFlavor::Gnu(Cc::Yes, _)
376+
| LinkerFlavor::Darwin(Cc::Yes, _)
377+
| LinkerFlavor::WasmLld(Cc::Yes)
378+
| LinkerFlavor::Unix(Cc::Yes)
379+
| LinkerFlavor::EmCc => true,
380+
LinkerFlavor::Gnu(..)
381+
| LinkerFlavor::Darwin(..)
382+
| LinkerFlavor::WasmLld(_)
383+
| LinkerFlavor::Msvc(_)
384+
| LinkerFlavor::Unix(_)
385+
| LinkerFlavor::Bpf
386+
| LinkerFlavor::Ptx => false,
387+
}
388+
}
370389
}
371390

372391
macro_rules! linker_flavor_cli_impls {

0 commit comments

Comments
 (0)