Expand description
build.rs helper: cross-compile a nub bare-metal Arch guest crate
for a stable bare-metal target (today: x86_64-unknown-none) and
return the path to the resulting ELF.
Today’s only consumer is nub-arch-x86. As we add more
bare-metal Arch backends (e.g. an arm/riscv guest), they live here
too — this crate owns the cross-compile recipe for all of nub’s
bare-metal arch guests.
Modeled on build-javm, but with two simplifications:
-
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.