Skip to main content

Target

Struct Target 

Source
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: TargetEnvironment

The C runtime and ABI. Left out of a target string, it is default_environment for the architecture and operating system.

§variant: ArchVariant

Sub-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

Source

pub fn new( architecture: TargetArchitecture, operating_system: TargetOperatingSystem, ) -> Self

Source

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.

Source

pub fn with_environment( self, environment: TargetEnvironment, ) -> Result<Self, String>

Select an environment the architecture accepts.

Source

pub fn spec(&self) -> ArchSpec

Everything the architecture states, as this target’s variant refines it.

Source

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.

Source

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.

Source

pub fn pointer_width(&self) -> PointerWidth

Source

pub fn has_64bit_int_registers(&self) -> bool

Source

pub fn endianness(&self) -> Endianness

Source

pub fn stack_alignment_at_call(&self) -> usize

Source

pub fn honors_argument_alignment(&self) -> bool

Source

pub fn output_artifact(&self) -> OutputArtifact

Source

pub fn data_layout(&self) -> TargetDataLayout

Source

pub fn interpreter(&self) -> Option<&'static str>

The ELF interpreter this target’s environment asks for, if it asks for one.

Source

pub fn gpu_triple(&self) -> Option<&'static str>

Source

pub fn to_str(&self) -> String

Source

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.

Trait Implementations§

Source§

impl Clone for Target

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Target

Source§

impl Debug for Target

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Target

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Target

Source§

impl FromStr for Target

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

fn from_str(target: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Target

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Target

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.