Expand description
Cross-compile a nub bare-metal Arch guest-kernel crate for a stable
bare-metal target (today: x86_64-unknown-none) and return the path
to the resulting ELF.
This is the ring-0 substrate that hosts the engine inside a
KVM/Hyperlight sandbox — not a PVM2 program. For those, see
crate::pvm2.
Today’s only consumer is javm-guest-x86 (the Javm personality
crate over the generic nub-arch-x86 kernel lib). As we add more
bare-metal Arch backends (e.g. an arm/riscv guest), they live here
too.
Two simplifications versus the PVM2 recipe:
-
No custom target JSON. We use the upstream stable target
x86_64-unknown-none(shipped since Rust 1.71). Thecore/alloc/compiler_builtinscome pre-built; no-Zbuild-stdneeded. -
No C toolchain. Hyperlight guests that link picolibc need a full cross-clang setup (which is why
cargo-hyperlightexists). Our guests usehyperlight-guest-binwithdefault-features = false, dropping the picolibc dependency entirely — pure Rust, no cc-rs, no bindgen.
What cargo-hyperlight does that we replicate as RUSTFLAGS:
--cfg=hyperlight+--check-cfg=cfg(hyperlight)— the hyperlight guest crates gate some code on this cfg.-Clink-args=-eentrypoint— make the symbolentrypointthe ELF entry point.
What cargo-hyperlight does that we skip:
- Building the sysroot (
-Zbuild-std) — unnecessary for stablex86_64-unknown-none. - Setting
CC_…,AR_…,CFLAGS_…— unnecessary without C.
Functions§
- build
- Cross-compile a hyperlight guest crate. Returns the path to the
resulting ELF binary, suitable for
include_bytes!or for passing tohyperlight_host::GuestBinary::FilePath.