An application template for Hermit for Rust.
(this is already done in this repo)
-
Add the
hermitdependency to your Cargo.toml:[target.'cfg(target_os = "hermit")'.dependencies] hermit = { git = "https://github.com/hermit-os/hermit-rs.git", tag = "hermit-0.13.0" }
Or use cargo-add:
cargo add hermit \ --target 'cfg(target_os = "hermit")' \ --git 'https://github.com/hermit-os/hermit-rs.git' \ --tag 'hermit-0.13.0' -
Make sure we link against hermit in
main.rs:#[cfg(target_os = "hermit")] use hermit as _;
See rust-std-hermit.
Note that rust-std-hermit is not available for the stable toolchain channel but for specific channels of stable Rust versions.
See rust-toolchain.toml.
$ cargo build --target x86_64-unknown-hermit
$ uhyve target/x86_64-unknown-hermit/debug/hermit-rs-template
For more details, see uhyve's README.
Download the loader binary from its releases page.
$ qemu-system-x86_64 \
-cpu qemu64,apic,fsgsbase,fxsr,rdrand,rdtscp,xsave,xsaveopt \
-smp 1 -m 128M \
-device isa-debug-exit,iobase=0xf4,iosize=0x04 \
-display none -serial stdio \
-kernel hermit-loader-x86_64 \
-initrd target/x86_64-unknown-hermit/debug/hermit-rs-template
For more details, see the loader's README.