-
Notifications
You must be signed in to change notification settings - Fork 33
Add option to enable pulley support for pre-compilation and runtime of modules and components #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -43,13 +43,25 @@ build-rust-wasm-examples target=default-target features="": (mkdir-redist target | |||||||
| cd ./src/rust_wasm_samples && cargo build --target wasm32-unknown-unknown --profile={{ if target == "debug" {"dev"} else { target } }} | ||||||||
| cargo run {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--features " + features } }} -p hyperlight-wasm-aot compile {{ if features =~ "gdb" {"--debug"} else {""} }} ./src/rust_wasm_samples/target/wasm32-unknown-unknown/{{ target }}/rust_wasm_samples.wasm ./x64/{{ target }}/rust_wasm_samples.aot | ||||||||
|
|
||||||||
| build-pulley-rust-wasm-examples target=default-target features="": (mkdir-redist target) | ||||||||
| rustup target add wasm32-unknown-unknown | ||||||||
| cd ./src/rust_wasm_samples && cargo build --target wasm32-unknown-unknown --profile={{ if target == "debug" {"dev"} else { target } }} | ||||||||
| cargo run {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--features " + features } }} -p hyperlight-wasm-aot compile --pulley {{ if features =~ "gdb" {"--debug"} else {""} }} ./src/rust_wasm_samples/target/wasm32-unknown-unknown/{{ target }}/rust_wasm_samples.wasm ./x64/{{ target }}/rust_wasm_samples.aot | ||||||||
|
|
||||||||
| build-rust-component-examples target=default-target features="": (compile-wit) | ||||||||
| # use cargo component so we don't get all the wasi imports https://github.com/bytecodealliance/cargo-component?tab=readme-ov-file#relationship-with-wasm32-wasip2 | ||||||||
| # we also explicitly target wasm32-unknown-unknown since cargo component might try to pull in wasi imports https://github.com/bytecodealliance/cargo-component/issues/290 | ||||||||
| rustup target add wasm32-unknown-unknown | ||||||||
| cd ./src/component_sample && cargo component build --target wasm32-unknown-unknown --profile={{ if target == "debug" {"dev"} else { target } }} | ||||||||
| cargo run {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--features " + features } }} -p hyperlight-wasm-aot compile {{ if features =~ "gdb" {"--debug"} else {""} }} --component ./src/component_sample/target/wasm32-unknown-unknown/{{ target }}/component_sample.wasm ./x64/{{ target }}/component_sample.aot | ||||||||
|
|
||||||||
| build-pulley-rust-component-examples target=default-target features="": (compile-wit) | ||||||||
| # use cargo component so we don't get all the wasi imports https://github.com/bytecodealliance/cargo-component?tab=readme-ov-file#relationship-with-wasm32-wasip2 | ||||||||
| # we also explicitly target wasm32-unknown-unknown since cargo component might try to pull in wasi imports https://github.com/bytecodealliance/cargo-component/issues/290 | ||||||||
| rustup target add wasm32-unknown-unknown | ||||||||
| cd ./src/component_sample && cargo component build --target wasm32-unknown-unknown --profile={{ if target == "debug" {"dev"} else { target } }} | ||||||||
| cargo run {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--features " + features } }} -p hyperlight-wasm-aot compile --pulley {{ if features =~ "gdb" {"--debug"} else {""} }} --component ./src/component_sample/target/wasm32-unknown-unknown/{{ target }}/component_sample.wasm ./x64/{{ target }}/component_sample.aot | ||||||||
|
||||||||
| cargo run {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--features " + features } }} -p hyperlight-wasm-aot compile --pulley {{ if features =~ "gdb" {"--debug"} else {""} }} --component ./src/component_sample/target/wasm32-unknown-unknown/{{ target }}/component_sample.wasm ./x64/{{ target }}/component_sample.aot | |
| mkdir {{ mkdir-arg }} x64/{{ target }}/pulley | |
| cargo run {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--features " + features } }} -p hyperlight-wasm-aot compile --pulley {{ if features =~ "gdb" {"--debug"} else {""} }} --component ./src/component_sample/target/wasm32-unknown-unknown/{{ target }}/component_sample.wasm ./x64/{{ target }}/pulley/component_sample.aot |
dblnz marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -111,6 +111,16 @@ pub extern "C" fn hyperlight_main() { | |||||||||||||||||
| config.with_custom_code_memory(Some(alloc::sync::Arc::new(platform::WasmtimeCodeMemory {}))); | ||||||||||||||||||
| #[cfg(gdb)] | ||||||||||||||||||
| config.debug_info(true); | ||||||||||||||||||
| #[cfg(pulley)] | ||||||||||||||||||
| config | ||||||||||||||||||
| .target("pulley64") | ||||||||||||||||||
| .map_err(|_| { | ||||||||||||||||||
| HyperlightGuestError::new( | ||||||||||||||||||
| ErrorCode::GuestError, | ||||||||||||||||||
| "Failed to set wasmtime target: pulley64".to_string(), | ||||||||||||||||||
| ) | ||||||||||||||||||
| }) | ||||||||||||||||||
| .unwrap(); | ||||||||||||||||||
|
Comment on lines
+117
to
+123
|
||||||||||||||||||
| .map_err(|_| { | |
| HyperlightGuestError::new( | |
| ErrorCode::GuestError, | |
| "Failed to set wasmtime target: pulley64".to_string(), | |
| ) | |
| }) | |
| .unwrap(); | |
| .expect("Failed to set wasmtime target: pulley64"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pulley-compiled binaries write to the same output path as the regular cranelift-compiled binaries (e.g.,
./x64/{{ target }}/rust_wasm_samples.aot). This means runningbuild-pulley-rust-wasm-exampleswill overwrite the output frombuild-rust-wasm-examples. Consider using distinct output paths (e.g.,./x64/{{ target }}/pulley/rust_wasm_samples.aot) to avoid accidental overwrites and allow both versions to coexist.