Skip to main content

Crate linux_targets

Crate linux_targets 

Source
Expand description

Linux target selection shared by the rustcommons toolchain.

A target is chosen in one of two ways:

  • A distribution preset (--distro sles-12-sp5): supplies the glibc floor, the kernel floor, and a container image with the real userland.
  • Explicit floors (--glibc 2.22, --kernel 4.12, or a versioned target such as x86_64-unknown-linux-gnu.2.22): each is optional. A missing kernel floor means the kernel is not simulated: programs run against the host kernel.

A preset cannot be combined with explicit floors: “SLES 12 SP5 with glibc 2.28” is not a real system. Selection::resolve enforces these rules.

use linux_targets::{Release, Request, Selection};

// A preset sets both floors and a test image.
let sles = Selection::resolve(&Request { distro: Some("sles-12-sp5"), ..Default::default() })?;
assert_eq!(sles.glibc, Some(Release::parse("2.22")?));
assert_eq!(sles.kernel, Some(Release::parse("4.12")?));
assert!(sles.image().is_some());

// A versioned target sets only the glibc floor; the kernel is not simulated.
let target = Selection::resolve(&Request {
    target: Some("x86_64-unknown-linux-gnu.2.17"),
    ..Default::default()
})?;
assert_eq!(target.triple.as_deref(), Some("x86_64-unknown-linux-gnu"));
assert_eq!(target.glibc, Some(Release::parse("2.17")?));
assert_eq!(target.kernel, None);
assert_eq!(target.describe(), "glibc 2.17, kernel not simulated (host)");

// A preset cannot be combined with explicit floors.
assert!(Selection::resolve(&Request {
    distro: Some("centos-7"),
    glibc: Some("2.28"),
    ..Default::default()
})
.is_err());

Structs§

Distro
A distribution preset: a kernel floor, a glibc floor, and a test image.
Release
A major.minor release number, such as a kernel (4.12) or glibc (2.22) release. Comparison uses only these two components.
Request
What the user selected, before validation.
Selection
A validated selection.

Functions§

distro
The preset with this id.
distros
All distribution presets from data/distros.tsv.
split_versioned_target
Splits x86_64-unknown-linux-gnu.2.17 into the Rust triple and the glibc floor. A triple without a numeric .X.Y suffix is returned unchanged.

Type Aliases§

GlibcVersion
A GNU C Library release.
KernelVersion
A mainline Linux kernel release.