Enum rustc_target::spec::LinkerFlavor
source · pub enum LinkerFlavor {
Gnu(Cc, Lld),
Darwin(Cc, Lld),
WasmLld(Cc),
Unix(Cc),
Msvc(Lld),
EmCc,
Bpf,
Ptx,
}
Expand description
All linkers have some kinds of command line interfaces and rustc needs to know which commands to use with each of them. So we cluster all such interfaces into a (somewhat arbitrary) number of classes that we call “linker flavors”.
Technically, it’s not even necessary, we can nearly always infer the flavor from linker name
and target properties like is_like_windows
/is_like_osx
/etc. However, the PRs originally
introducing -Clinker-flavor
(#40018 and friends) were aiming to reduce this kind of inference
and provide something certain and explicitly specified instead, and that design goal is still
relevant now.
The second goal is to keep the number of flavors to the minimum if possible.
LLD somewhat forces our hand here because that linker is self-sufficient only if its executable
(argv[0]
) is named in specific way, otherwise it doesn’t work and requires a
-flavor LLD_FLAVOR
argument to choose which logic to use. Our shipped rust-lld
in
particular is not named in such specific way, so it needs the flavor option, so we make our
linker flavors sufficiently fine-grained to satisfy LLD without inferring its flavor from other
target properties, in accordance with the first design goal.
The first component of the flavor is tightly coupled with the compilation target,
while the Cc
and Lld
flags can vary withing the same target.
Variants§
Gnu(Cc, Lld)
Unix-like linker with GNU extensions (both naked and compiler-wrapped forms). Besides similar “default” Linux/BSD linkers this also includes Windows/GNU linker, which is somewhat different because it doesn’t produce ELFs.
Darwin(Cc, Lld)
Unix-like linker for Apple targets (both naked and compiler-wrapped forms).
Extracted from the “umbrella” Unix
flavor due to its corresponding LLD flavor.
WasmLld(Cc)
Unix-like linker for Wasm targets (both naked and compiler-wrapped forms).
Extracted from the “umbrella” Unix
flavor due to its corresponding LLD flavor.
Non-LLD version does not exist, so the lld flag is currently hardcoded here.
Unix(Cc)
Basic Unix-like linker for “any other Unix” targets (Solaris/illumos, L4Re, MSP430, etc), possibly with non-GNU extensions (both naked and compiler-wrapped forms). LLD doesn’t support any of these.
Msvc(Lld)
MSVC-style linker for Windows and UEFI, LLD supports it.
EmCc
Emscripten Compiler Frontend, a wrapper around WasmLld(Cc::Yes)
that has a different
interface and produces some additional JavaScript output.
Bpf
Linker tool for BPF.
Ptx
Linker tool for Nvidia PTX.
Implementations§
source§impl LinkerFlavor
impl LinkerFlavor
pub fn from_cli(cli: LinkerFlavorCli, target: &TargetOptions) -> LinkerFlavor
sourcefn from_cli_impl(
cli: LinkerFlavorCli,
lld_flavor: LldFlavor,
is_gnu: bool
) -> LinkerFlavor
fn from_cli_impl(
cli: LinkerFlavorCli,
lld_flavor: LldFlavor,
is_gnu: bool
) -> LinkerFlavor
The passed CLI flavor is preferred over other args coming from the default target spec,
so this function can produce a flavor that is incompatible with the current target.
FIXME: Produce errors when -Clinker-flavor
is set to something incompatible
with the current target.
fn to_cli(self) -> LinkerFlavorCli
pub fn lld_flavor(self) -> LldFlavor
pub fn is_gnu(self) -> bool
Trait Implementations§
source§impl Clone for LinkerFlavor
impl Clone for LinkerFlavor
source§fn clone(&self) -> LinkerFlavor
fn clone(&self) -> LinkerFlavor
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for LinkerFlavor
impl Debug for LinkerFlavor
source§impl Ord for LinkerFlavor
impl Ord for LinkerFlavor
source§fn cmp(&self, other: &LinkerFlavor) -> Ordering
fn cmp(&self, other: &LinkerFlavor) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<LinkerFlavor> for LinkerFlavor
impl PartialEq<LinkerFlavor> for LinkerFlavor
source§fn eq(&self, other: &LinkerFlavor) -> bool
fn eq(&self, other: &LinkerFlavor) -> bool
source§impl PartialOrd<LinkerFlavor> for LinkerFlavor
impl PartialOrd<LinkerFlavor> for LinkerFlavor
source§fn partial_cmp(&self, other: &LinkerFlavor) -> Option<Ordering>
fn partial_cmp(&self, other: &LinkerFlavor) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for LinkerFlavor
impl Eq for LinkerFlavor
impl StructuralEq for LinkerFlavor
impl StructuralPartialEq for LinkerFlavor
Auto Trait Implementations§
impl RefUnwindSafe for LinkerFlavor
impl Send for LinkerFlavor
impl Sync for LinkerFlavor
impl Unpin for LinkerFlavor
impl UnwindSafe for LinkerFlavor
Blanket Implementations§
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 3 bytes
Size for each variant:
Gnu
: 2 bytesDarwin
: 2 bytesWasmLld
: 1 byteUnix
: 1 byteMsvc
: 1 byteEmCc
: 0 bytesBpf
: 0 bytesPtx
: 0 bytes