Skip to main content

Crate nub_build

Crate nub_build 

Source
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:

  1. No custom target JSON. We use the upstream stable target x86_64-unknown-none (shipped since Rust 1.71). The core/alloc/compiler_builtins come pre-built; no -Zbuild-std needed.

  2. No C toolchain. Hyperlight guests that link picolibc need a full cross-clang setup (which is why cargo-hyperlight exists). Our guests use hyperlight-guest-bin with default-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 symbol entrypoint the ELF entry point.

What cargo-hyperlight does that we skip:

  • Building the sysroot (-Zbuild-std) — unnecessary for stable x86_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 to hyperlight_host::GuestBinary::FilePath.