cargo-hyperlight
A cargo subcommand to build hyperlight guest binaries.
Write a hyperlight guest binary in Rust, and build it with a simple
And there's no need for any extra configuration.
Your binary, or any of its dependencies, can have a build.rs script using cc and bindgen to compile C code and generate bindings.
They will work out of the box!
[!NOTE] Your crate must have
hyperlight-guest-binas a transitive dependency.
Installation
Usage
Create a new crate for your hyperlight guest binary:
In your Cargo.toml
[]
= "guest"
= "0.1.0"
= "2024"
[]
= { = "0.11.0", = false }
= "0.11.0"
= "0.11.0"
The in your src/main.rs
extern crate alloc;
use Vec;
use ;
use Result;
use ;
use *;
pub extern "C"
Then to build the hyperlight guest binary, run
Your binary will be built for the x86_64-hyperlight-none target (or aarch64-hyperlight-none on ARM) by default, and placed in target/<arch>-hyperlight-none/release/guest.
There's no need for any extra configuration, the command will take care of everything.
Building C Guests
cargo-hyperlight also supports building C guest binaries. To get the compiler and linker flags needed to build a C guest, use:
For example, to compile and link a C guest:
Building a C Sysroot
To produce a self-contained, redistributable C sysroot (including headers, libraries, a hyperlight-config utility, and a clang wrapper), use:
This copies the following into the specified directory:
bin/— ahyperlight-configexecutable and aclangwrapperinclude/— header files for the guest C APIlib/— static libraries needed to link a C guest
The produced hyperlight-config executable provides the same --cflags, --ldflags, and --libs flags, and the clang wrapper automatically injects the correct flags when invoked. This allows downstream consumers to build C guests without installing cargo-hyperlight themselves.
Releasing
To publish a new version:
- Update the version in
Cargo.toml - Commit the change:
git commit -S -s -am "Bump version to X.Y.Z"and open a PR - Create and push a tag:
git tag -s vX.Y.Z && git push origin vX.Y.Z
The CI will automatically run tests, publish to crates.io, and create a GitHub release.