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
impl Kernel
Sourcepub fn for_target(cache: &Path, target: TargetTuple) -> Option<Kernel>
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.
Sourcepub fn arch_include(&self) -> PathBuf
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.
Sourcepub fn generic_include(&self) -> PathBuf
pub fn generic_include(&self) -> PathBuf
linux/, asm-generic/ and the rest, which are the same files for every architecture.