Skip to main content

Sysroot

Struct Sysroot 

Source
pub struct Sysroot { /* private fields */ }
Expand description

One target’s sysroot: where its headers are, where its link inputs are, and where the record of what they are is.

Constructed rather than discovered. Nothing here checks that any of these directories exists, because the caller that is about to produce a sysroot needs the same answer as the caller that is about to read one, and a constructor that failed for an absent directory would give the first one nothing to create.

Implementations§

Source§

impl Sysroot

Source

pub fn in_cache(cache: &Path, target: TargetTuple) -> Self

The sysroot for this target inside this cache directory.

The path is <cache>/sysroots/<canonical tuple>. Two hosts running this with the same cache directory and the same target get the same path, which is what makes the tuple a cache key and is the reason spec/cross-compile/03-target-model.md section 3.2 admits a field only when it changes how a call is made or a struct is laid out.

Source

pub fn at(root: PathBuf, target: TargetTuple) -> Self

A sysroot rooted at a directory the user named, with --sysroot or -isysroot.

The layout below the root is the same, so a user who assembled a tree the way we lay one out is served by every other method here. A user who did not is served by Options::sysroot, which replaces step 3 of section 8.5 wholesale rather than assuming a shape.

Source

pub const fn target(&self) -> TargetTuple

The target this sysroot is for.

Source

pub fn root(&self) -> &Path

The directory everything else here is under.

Source

pub fn cache_key(&self) -> String

The cache key, which is the canonical spelling of the tuple.

The whole tuple and not a summary of it. A key that dropped env_version would serve a sysroot built against glibc 2.28 to a target that pinned 2.34, and the failure would be a missing symbol at link time on one machine and not on another.

Source

pub fn arch_include(&self) -> PathBuf

The headers that differ by architecture, which are searched before the generic ones.

Section 8.3’s second split. For musl this is bits/, which is a few dozen small files against a few hundred shared ones, so the copy per architecture is cheap and the alternative of one whole tree per architecture is not.

Source

pub fn generic_include(&self) -> PathBuf

The headers every architecture shares, which is almost all of them.

Source

pub fn includes(&self) -> Vec<PathBuf>

Both include directories, in search order, most specific first.

Source

pub fn lib(&self) -> PathBuf

The link inputs: the start files, the libc archive or its generated stubs, and the compiler’s own runtime for this target.

Source

pub fn manifest_path(&self) -> PathBuf

The manifest naming every input with its source, its hash and its licence.

A file rather than a directory, and at the top rather than beside the libraries, because the thing a person does with it is read it first.

Source

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

The name the target’s libc gives to its per architecture header directory.

Not the architecture component of the canonical tuple, which carries a baseline the headers do not care about: armv7a-linux-musleabihf and armv5te-linux-musleabi read the same arm directory, because a header does not know which instructions the chip has. 32-bit x86 is i386 in every libc’s source tree whatever the tuple spells it.

The data model is here because an ILP32 ABI on a 64-bit architecture cannot read the LP64 tree. Every type in the headers that carries a pointer or a long is a different size, so it gets its own directory, and x86_64-linux-gnux32 is the row in the table that proves it. Any future ILP32-on-64 row gets a suffixed name from the same rule rather than quietly reading the LP64 headers, which is the failure this method is arranged to make impossible.

Trait Implementations§

Source§

impl Clone for Sysroot

Source§

fn clone(&self) -> Sysroot

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 Debug for Sysroot

Source§

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

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

impl Eq for Sysroot

Source§

impl PartialEq for Sysroot

Source§

fn eq(&self, other: &Sysroot) -> 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 Sysroot

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, 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.