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 asx86_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.minorrelease 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.17into the Rust triple and the glibc floor. A triple without a numeric.X.Ysuffix is returned unchanged.
Type Aliases§
- Glibc
Version - A GNU C Library release.
- Kernel
Version - A mainline Linux kernel release.