pub enum LinkerFlavor {
    Gnu(CcLld),
    Darwin(CcLld),
    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(CcLld)

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(CcLld)

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§

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.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

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 bytes
  • Darwin: 2 bytes
  • WasmLld: 1 byte
  • Unix: 1 byte
  • Msvc: 1 byte
  • EmCc: 0 bytes
  • Bpf: 0 bytes
  • Ptx: 0 bytes