Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/Benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ jobs:
with:
rust-toolchain: "1.89"

- name: Build Wasm Runtime Binary
working-directory: ./src/hyperlight_wasm
run: just build-wasm-runtime ${{ matrix.config }}

- uses: dtolnay/[email protected]
with:
components: clippy, rustfmt
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/dep_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ jobs:
if: runner.os == 'Windows'
run: rustup component add --toolchain nightly-x86_64-pc-windows-msvc rustfmt

- name: Build Wasm Runtime Binary
working-directory: ./src/hyperlight_wasm
run: just build-wasm-runtime ${{ matrix.config }}

- name: Download Wasm Modules
uses: actions/download-artifact@v5
with:
Expand Down
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
// This is needed to allow tests to find files when running under the debugger
"rust-analyzer.runnables.extraEnv": {
"RUST_DIR_FOR_DEBUGGING_TESTS": "${workspaceFolder}/src/hyperlight_wasm"
}
},

// Include wasm_runtime directory for rust-analyzer support
"rust-analyzer.linkedProjects": [
"${workspaceFolder}/src/wasm_runtime/Cargo.toml"
]
}
108 changes: 102 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ readme = "README.md"

[workspace.dependencies]
hyperlight-host = { version = "0.11.0", default-features = false, features = ["executable_heap", "init-paging"] }

[patch.crates-io]
hyperlight-host = { git = "https://github.com/hyperlight-dev/hyperlight", rev = "5bfe0bfdf2f168b48bf6242d8eed84d54fab1186" }
15 changes: 8 additions & 7 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ ensure-tools:
cargo install wasm-tools --locked --version 1.235.0
cargo install cargo-component --locked --version 0.21.1
cargo install wit-bindgen-cli --locked --version 0.43.0
cargo install cargo-hyperlight --locked --version 0.1.4

build-all target=default-target features="": (build target features) (build-wasm-examples target features) (build-rust-wasm-examples target features) (build-rust-component-examples target) (build-wasm-runtime target features)
build-all target=default-target features="": (build target features) (build-examples target features)

build target=default-target features="": (fmt-check)
cargo build {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--no-default-features -F " + features } }} --verbose --profile={{ if target == "debug" {"dev"} else { target } }}
Expand All @@ -32,10 +33,9 @@ compile-wit:
wasm-tools component wit ./src/wasmsamples/components/runcomponent.wit -w -o ./src/wasmsamples/components/runcomponent-world.wasm
wasm-tools component wit ./src/component_sample/wit/example.wit -w -o ./src/component_sample/wit/component-world.wasm

build-wasm-runtime target=default-target features="":
cd ./src/wasm_runtime && cargo build --verbose {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--features " + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} && rm -R target
build-examples target=default-target features="": (build-wasm-examples target features) (build-rust-wasm-examples target features) (build-rust-component-examples target features)

build-wasm-examples target=default-target features="": (compile-wit)
build-wasm-examples target=default-target features="": (compile-wit)
{{ build-wasm-examples-command }} {{target}} {{features}}

build-rust-wasm-examples target=default-target features="": (mkdir-redist target)
Expand All @@ -54,7 +54,7 @@ check target=default-target:
cargo check --profile={{ if target == "debug" {"dev"} else { target } }}
cd src/rust_wasm_samples && cargo check --profile={{ if target == "debug" {"dev"} else { target } }}
cd src/component_sample && cargo check --profile={{ if target == "debug" {"dev"} else { target } }}
cd src/wasm_runtime && cargo check --profile={{ if target == "debug" {"dev"} else { target } }}
cd src/wasm_runtime && cargo hyperlight check --profile={{ if target == "debug" {"dev"} else { target } }}
cd src/hyperlight_wasm_macro && cargo check --profile={{ if target == "debug" {"dev"} else { target } }}

fmt-check:
Expand All @@ -79,7 +79,7 @@ clippy target=default-target: (check target)
cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
cd src/rust_wasm_samples && cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
cd src/component_sample && cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
cd src/wasm_runtime && cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
cd src/wasm_runtime && cargo hyperlight clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
cd src/hyperlight_wasm_macro && cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings

# TESTING
Expand All @@ -100,7 +100,8 @@ examples-ci target=default-target features="": (build-rust-wasm-examples target)
cargo run {{ if features =="" {"--no-default-features --features kvm,mshv3"} else {"--no-default-features -F function_call_metrics," + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} --example metrics

examples-components target=default-target features="": (build-rust-component-examples target)
{{ wit-world }} cargo run {{ if features =="" {''} else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} --example component_example
{{ wit-world }} cargo run {{ if features =="" {''} else {"--no-default-features -F kvm -F " + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} --example component_example
{{ wit-world-c }} cargo run {{ if features =="" {''} else {"--no-default-features -F kvm -F " + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} --example c-component

# warning, compares to and then OVERWRITES the given baseline
bench-ci baseline target="release" features="":
Expand Down
3 changes: 2 additions & 1 deletion src/hyperlight_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ hyperlight-host = { workspace = true }
libc = { version = "0.2.178" }
once_cell = "1.21.3"
tracing = "0.1.43"
log = "0.4.29"
log = "0.4"
cfg-if = { version = "1" }
metrics = "0.24.3"
env_logger = "0.11.8"
Expand Down Expand Up @@ -101,6 +101,7 @@ built = { version = "0.8.0", features = ["chrono", "git2"] }
anyhow = { version = "1.0" }
goblin = "0.10.4"
tar = "0.4.44"
cargo-hyperlight = "0.1.4"

[target.'cfg(windows)'.build-dependencies]
junction = "1"
Expand Down
32 changes: 7 additions & 25 deletions src/hyperlight_wasm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,14 @@ limitations under the License.
// this file is included in lib.rs.
// The wasm_runtime binary is expected to be in the x64/{config} directory.

use std::ffi::OsString;
use std::fs::OpenOptions;
use std::io::Write;
use std::iter::once;
use std::path::{Path, PathBuf};
use std::{env, fs};

use anyhow::Result;
use built::write_built_file;

fn path_with(path: impl Into<PathBuf>) -> OsString {
let path = path.into();
let paths = env::var_os("PATH").unwrap_or_default();
let paths = env::split_paths(&paths);
let paths = once(path).chain(paths);
env::join_paths(paths).unwrap()
}

fn get_wasm_runtime_path() -> PathBuf {
let manifest_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap();
let manifest_dir = PathBuf::from(manifest_dir);
Expand Down Expand Up @@ -100,12 +90,10 @@ fn get_wasm_runtime_path() -> PathBuf {
}

fn build_wasm_runtime() -> PathBuf {
let cargo_bin = env::var_os("CARGO").unwrap();
let profile = env::var_os("PROFILE").unwrap();
let out_dir = env::var_os("OUT_DIR").unwrap();

let target_dir = Path::new("").join(&out_dir).join("target");
let toolchain_dir = Path::new("").join(&out_dir).join("toolchain");

let in_repo_dir = get_wasm_runtime_path();

Expand All @@ -124,21 +112,18 @@ fn build_wasm_runtime() -> PathBuf {
let mut env_vars = env::vars().collect::<Vec<_>>();
env_vars.retain(|(key, _)| !key.starts_with("CARGO_"));

let mut cargo_cmd = std::process::Command::new(&cargo_bin);
let mut cargo_cmd = cargo_hyperlight::cargo().unwrap();
let mut cmd = cargo_cmd
.arg("build")
.arg("--target-dir")
.arg(&target_dir)
.arg("--profile")
.arg(cargo_profile)
.arg("-v")
.arg("--target-dir")
.arg(&target_dir)
.current_dir(&in_repo_dir)
.env_clear()
// On windows when `gdb` features is enabled this is not set correctly
.env("CFLAGS_x86_64_unknown_none", "-fPIC")
.envs(env_vars)
.env("PATH", path_with(&toolchain_dir))
.env("HYPERLIGHT_GUEST_TOOLCHAIN_ROOT", &toolchain_dir);
.env("CFLAGS_x86_64_unknown_none", "-fPIC"); // Should this go on cargo hyperlight

// Add --features gdb if the gdb feature is enabled for this build script
if std::env::var("CARGO_FEATURE_GDB").is_ok() {
Expand All @@ -149,14 +134,11 @@ fn build_wasm_runtime() -> PathBuf {
cmd = cmd.arg("--features").arg("trace_guest");
}

let status = cmd
.status()
cmd.status()
.unwrap_or_else(|e| panic!("could not run cargo build wasm_runtime: {}", e));
if !status.success() {
panic!("could not compile wasm_runtime");
}

let resource = target_dir
.join("x86_64-unknown-none")
.join("x86_64-hyperlight-none")
.join(profile)
.join("wasm_runtime");

Expand Down
Loading