pub struct Target {
pub architecture: TargetArchitecture,
pub operating_system: TargetOperatingSystem,
pub environment: TargetEnvironment,
pub variant: ArchVariant,
}Expand description
A target: what to generate code for, and what to link it against.
The four axes are independent and each is declared, never inferred from the build
machine. The target-string grammar is <architecture>_<operating-system>[_<environment>],
where the architecture field may name a sub-architecture variant (rv64gc,
aarch64v8.2) and the environment field may be left out, in which case the
architecture’s declared default for that operating system applies.
Fields§
§architecture: TargetArchitecture§operating_system: TargetOperatingSystem§environment: TargetEnvironmentThe C runtime and ABI. Left out of a target string, it is
default_environment for the architecture and operating system.
variant: ArchVariantSub-architecture the target string selected. Every spelling that names only the
architecture gets the architecture’s crate::VariantAxis default, which is what
that spelling has always meant.
Implementations§
Source§impl Target
impl Target
pub fn new( architecture: TargetArchitecture, operating_system: TargetOperatingSystem, ) -> Self
Sourcepub fn with_variant(self, variant: ArchVariant) -> Self
pub fn with_variant(self, variant: ArchVariant) -> Self
Select a sub-architecture. A variant of another family is replaced by the architecture’s default, so the target stays consistent.
Sourcepub fn with_environment(
self,
environment: TargetEnvironment,
) -> Result<Self, String>
pub fn with_environment( self, environment: TargetEnvironment, ) -> Result<Self, String>
Select an environment the architecture accepts.
Sourcepub fn spec(&self) -> ArchSpec
pub fn spec(&self) -> ArchSpec
Everything the architecture states, as this target’s variant refines it.
Sourcepub fn arch_token(&self) -> String
pub fn arch_token(&self) -> String
Architecture half of the target string, carrying the variant when it is not the
default, so Display and FromStr stay inverses.
Sourcepub fn implied_environment(&self) -> TargetEnvironment
pub fn implied_environment(&self) -> TargetEnvironment
The environment the rest of the target string already implies, and so the one the environment field is left out for.
pub fn pointer_width(&self) -> PointerWidth
pub fn has_64bit_int_registers(&self) -> bool
pub fn endianness(&self) -> Endianness
pub fn stack_alignment_at_call(&self) -> usize
pub fn honors_argument_alignment(&self) -> bool
pub fn output_artifact(&self) -> OutputArtifact
pub fn data_layout(&self) -> TargetDataLayout
Sourcepub fn interpreter(&self) -> Option<&'static str>
pub fn interpreter(&self) -> Option<&'static str>
The ELF interpreter this target’s environment asks for, if it asks for one.
pub fn gpu_triple(&self) -> Option<&'static str>
pub fn to_str(&self) -> String
Sourcepub fn detect_host() -> Result<Self, String>
pub fn detect_host() -> Result<Self, String>
Detect the host system’s target.
§Examples
use lamina_platform::Target;
let host = Target::detect_host().expect("host is a supported target");
println!("Host target: {}", host);Fails for a host whose architecture or OS lamina has no backend for, rather than guessing a target for it.