pub struct Triple {
pub arch: Arch,
pub os: Os,
pub env: Env,
}Expand description
A target triple.
We accept the LLVM-style arch-vendor-os-env form because that is what build systems
pass, and we normalise it to the three fields we actually branch on. The vendor field is
parsed and discarded: no decision in the compiler depends on it, and keeping it would
invite one.
Fields§
§arch: ArchThe architecture.
os: OsThe operating system.
env: EnvThe runtime and ABI variant.
Implementations§
Source§impl Triple
impl Triple
Sourcepub fn tuple(self) -> TargetTuple
pub fn tuple(self) -> TargetTuple
The same machine as a TargetTuple, which is what the layout and ABI descriptions are
written over.
The tuple carries ten fields and this carries three, so this fills the other seven in from
their defaults, and every one of those defaults is the answer for the targets this type can
spell. There is no x32 here and no big-endian AArch64, so the data model and the byte
order follow the architecture, and the sub-architecture, the versions and the float ABI have
nothing to say about any of the combinations.
The environment is narrowed rather than copied across. This type will hold
Triple { os: Darwin, env: Gnu }, because its parser takes the fields by content and
aarch64-apple-darwin-gnu is a string somebody can type, and that is not a machine: a
Darwin target has one libc and it is not glibc. A tuple refuses to describe one, so the
pairs that are not machines are mapped to the environment the operating system actually
has.
§Panics
Never, for a triple this type can hold, which every_triple_describes_a_machine checks by
building all forty eight of them.
Sourcepub fn from_tuple(target: TargetTuple) -> Option<Triple>
pub fn from_tuple(target: TargetTuple) -> Option<Triple>
The triple that describes the same machine as target, if this type can spell it.
The inverse of Triple::tuple, and computed by running that function over every triple
there is rather than by writing the narrowing out a second time. A second table would be a
second thing to keep in step, and the failure it invites is not a compile error: it is one
row of the matrix quietly answering as a neighbour.
It returns None for most of the target table, and that is the honest answer rather than a
gap to be papered over. rucc-abi describes the scalar layout of all forty two rows, and
this type holds three fields with three architectures in the first, so seventeen of those
rows have a TargetInfo and the other twenty five do not. Anything that needs to lay a
record out for s390x-linux-gnu needs that gap closed rather than an approximation of it.
The environment of the answer is the narrowed one, so the triple this gives back is the
canonical spelling of that machine: Env::None on Darwin and on a freestanding target,
never the Env::Gnu that a parser will accept from a string somebody typed.