Expand description
The target tuple for rucc.
A target is not three strings. It is the set of facts that change the bytes the compiler
emits, and there are ten of them: the architecture, the baseline within it, the byte order,
the data model, the OS, the OS version, the environment, the environment version, the float
ABI, and the object format. spec/cross-compile/03-target-model.md argues for each one, and the argument
is always the same: if the fact changes how a function is called or how a struct is laid out,
then two objects that disagree about it do not link, so it is part of the target’s identity
and not a flag.
That identity property is what the rest of the cross compilation work is built on. The
sysroot cache in spec/cross-compile/13-distribution.md is keyed on a tuple, the stub libraries in
spec/cross-compile/09-libc-stubs.md are generated per tuple, and the report that decides a target’s tier
is indexed by tuple. All three break if two spellings of one target produce two keys, or if
one spelling produces two different sets of bytes.
§What this replaces
The compiler currently has a three field Triple with the architecture, the OS and the
environment, and two functions on Arch that answer the pointer width and the byte order.
Both functions are wrong for targets in spec/cross-compile/04-target-matrix.md: a 64-bit architecture on
Windows has a 32-bit long, x86_64-linux-gnux32 has 32-bit pointers, and five of the ten
architectures here have a big endian mode. The old FromStr also had a catch-all arm that
discarded any component it did not recognize, so x86_64-linux-gnu.2.28 parsed as
x86_64-linux-gnu and the pinned glibc version vanished without a word.
§Example
use rucc_tuple::{DataModel, ObjectFormat, TargetTuple};
let target: TargetTuple = "x86_64-pc-windows-msvc".parse().unwrap();
assert_eq!(target.data_model(), DataModel::Llp64);
assert_eq!(target.data_model().long_width(), 32);
assert_eq!(target.pointer_width(), 64);
assert_eq!(target.object_format(), ObjectFormat::Coff);
assert_eq!(target.to_canonical_string(), "x86_64-windows-msvc");
assert_eq!(target.to_llvm_string(), "x86_64-pc-windows-msvc");Structs§
- Target
Entry - One row of the target table.
- Target
Tuple - Everything about a target that changes the bytes the compiler emits.
- Tuple
Builder - The parts a caller supplies, with the rest derived.
- Version
- A version attached to an OS or to an environment.
Enums§
- Abi
- The variant of the platform ABI that decides where floating point arguments go.
- Arch
- An instruction set family.
- Data
Model - The widths of
int,longand a pointer, as one choice rather than three. - Endian
- Byte order.
- Env
- The environment component of a tuple.
- Error
- A tuple that could not be read, or that was read and does not describe a machine.
- Host
- Whether rucc itself runs on this target, which is a separate and much cheaper question from whether rucc compiles for it.
- Object
Format - The container the compiler writes.
- Os
- An operating system, in the sense of the thing that defines the syscall interface, the object format, the start files and the availability of a declaration.
- SubArch
- A baseline within an architecture family.
- Tier
- What is known to be true about a target.
Constants§
- TARGETS
- Every target the compiler has an opinion about.
Functions§
- counts_
by_ planned_ tier - How many rows are at each tier today, and how many the plan commits to.
- lookup
- Find the table row for a target, by canonical spelling.
- planned_
working_ count - How many rows the plan commits to compiling and linking, which is the number claim 1 is measured against.