Target

Enum Target 

Source
pub enum Target {
    X86_64Linux,
    Aarch64Linux,
    Aarch64Macos,
}
Expand description

A compilation target consisting of an architecture and operating system.

Variants§

§

X86_64Linux

x86-64 Linux (System V AMD64 ABI)

§

Aarch64Linux

AArch64 Linux (AAPCS64 ABI)

§

Aarch64Macos

AArch64 macOS (Apple Silicon, AAPCS64 with Apple extensions)

Implementations§

Source§

impl Target

Source

pub fn host() -> Self

Detect the host target at compile time.

Returns the target that matches the current compilation environment. This is useful for defaulting to native compilation.

Source

pub fn arch(&self) -> Arch

Returns the architecture component of this target.

Source

pub fn os(&self) -> Os

Returns the operating system component of this target.

Source

pub fn elf_machine(&self) -> Option<u16>

Returns the ELF e_machine value for this target, if it uses ELF format.

This is used when generating ELF object files and executables. Returns None for targets that don’t use ELF (e.g., macOS uses Mach-O).

Source

pub fn page_size(&self) -> u64

Returns the default page size for this target in bytes.

This is used for executable segment alignment.

Source

pub fn default_base_addr(&self) -> u64

Returns the default base address for executables on this target.

This is the virtual address where the executable is loaded.

Source

pub fn pointer_size(&self) -> u32

Returns the pointer size in bytes for this target.

Source

pub fn stack_alignment(&self) -> u32

Returns the required stack alignment in bytes for this target.

This is the alignment required at function call boundaries.

Source

pub fn triple(&self) -> &'static str

Returns the triple string for this target (e.g., “x86_64-unknown-linux-gnu”).

This can be useful for invoking external tools like system linkers.

Source

pub fn is_macho(&self) -> bool

Returns whether this target uses Mach-O object format (macOS).

Source

pub fn is_elf(&self) -> bool

Returns whether this target uses ELF object format (Linux).

Source

pub fn macos_min_version(&self) -> Option<u32>

Returns the minimum macOS version for this target, encoded for Mach-O.

The version is encoded as 0x00XXYYPP where XX is major, YY is minor, PP is patch. For example, macOS 11.0.0 (Big Sur) is encoded as 0x000B0000.

Returns None for non-macOS targets.

Note: macOS 11.0 (Big Sur) was the first version to support Apple Silicon (ARM64), which is why it’s the minimum for Aarch64Macos.

Source

pub fn all() -> &'static [Target]

Returns all supported targets.

Source

pub fn all_names() -> &'static str

Returns a comma-separated string of all target names for help text.

Trait Implementations§

Source§

impl Clone for Target

Source§

fn clone(&self) -> Target

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Target

Source§

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

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

impl Default for Target

Source§

fn default() -> Self

Returns the host target as the default.

This allows code to write Target::default() instead of Target::host(), which is useful for struct initialization with ..Default::default().

Source§

impl Display for Target

Source§

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

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

impl FromStr for Target

Source§

type Err = ParseTargetError

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

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

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

impl Hash for Target

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Target

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Target

Source§

impl Eq for Target

Source§

impl StructuralPartialEq for Target

Auto Trait Implementations§

§

impl Freeze for Target

§

impl RefUnwindSafe for Target

§

impl Send for Target

§

impl Sync for Target

§

impl Unpin for Target

§

impl UnwindSafe for Target

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.