Skip to main content

Kernel

Struct Kernel 

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

The kernel’s own headers, which are not the libc’s and are shared by every target that can read them.

linux/ and asm/ are the system call interface rather than the C library, and a sysroot without them does not compile 31 of glibc’s installed headers or 3 of musl’s, sys/quota.h and net/ethernet.h among them. So they are part of what section 8.2 calls a sysroot even though no libc produced them.

§Why they are not under Sysroot

One tree serves every libc and every architecture except asm/, which is per architecture and small. Copying the shared part into each tuple’s sysroot would be nine megabytes times the number of Linux rows in the table, for files that are identical in every copy. So the root is the cache directory rather than a sysroot, and a sysroot that was produced with it records the version in its manifest, which is crate::Manifest::kernel and the kernel line of the format. The tree carries its own record as well, headed rucc kernel headers manifest 1, because one tree serves every target and a sysroot manifest names one. Nothing checks the two against each other: a sysroot can be produced beside one tree and read beside another, and the manifest makes that visible rather than preventing it.

§Why the version is not in the path

The driver has to be able to compute this path before it reads anything, and a version in the path would mean asking the cache what it has before being able to ask where it is. It is the same decision Sysroot::in_cache makes about the libc version, where the tuple carries the version only because env_version is part of the target’s identity, and the same gap: a cache populated by one release and read by the next gets whatever is there.

That gap does not close by putting a hash in a path, which is what spec/cross-compile/13-distribution.md section 13.2 used to say and what tamnd/rucc#1021 settled: a path has to be known before anything has been read. What closes it is comparing a record against one somebody published, and the record says which release it was, here as the tree’s own manifest and in a sysroot as crate::Manifest::kernel.

Implementations§

Source§

impl Kernel

Source

pub fn for_target(cache: &Path, target: TargetTuple) -> Option<Kernel>

The kernel headers in this cache directory for this target, when the target has any.

None for everything that is not Linux with a libc we produce a tree for. Windows, the BSDs and Darwin have their own system headers and no linux/ at all, freestanding has no system call interface by definition, and Android is Linux but bionic carries its own scrubbed copy of the uapi headers, which is a different tree from this one and not a subset of it.

Source

pub fn root(&self) -> &Path

The directory both of these are under.

Source

pub fn arch_include(&self) -> PathBuf

asm/, which is the part of the interface that is per architecture.

Named after the kernel’s own architecture directory and not after ours or the libc’s, which is a third spelling of the same machine and the reason this is a method rather than a format string at the call site.

Source

pub fn generic_include(&self) -> PathBuf

linux/, asm-generic/ and the rest, which are the same files for every architecture.

Source

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

Both directories, in search order, most specific first.

Source

pub const fn arch(&self) -> &'static str

The kernel’s name for this architecture.

Trait Implementations§

Source§

impl Clone for Kernel

Source§

fn clone(&self) -> Kernel

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 Kernel

Source§

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

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

impl Eq for Kernel

Source§

impl PartialEq for Kernel

Source§

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

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.