Skip to content

Commit 0739693

Browse files
authored
Remove aot acting as wasm (#115)
Signed-off-by: James Sturtevant <[email protected]>
1 parent 9c1a1bc commit 0739693

File tree

15 files changed

+69
-112
lines changed

15 files changed

+69
-112
lines changed

.github/workflows/dep_build_wasm_examples.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,4 @@ jobs:
8787
with:
8888
name: guest-modules
8989
path: |
90-
x64/release/*.wasm
9190
x64/release/*.aot

Justfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ build-rust-wasm-examples target=default-target: (mkdir-redist target)
4242
rustup target add wasm32-unknown-unknown
4343
cd ./src/rust_wasm_samples && cargo build --target wasm32-unknown-unknown --profile={{ if target == "debug" {"dev"} else { target } }}
4444
cargo run -p hyperlight-wasm-aot compile ./src/rust_wasm_samples/target/wasm32-unknown-unknown/{{ target }}/rust_wasm_samples.wasm ./x64/{{ target }}/rust_wasm_samples.aot
45-
cp ./x64/{{ target }}/rust_wasm_samples.aot ./x64/{{ target }}/rust_wasm_samples.wasm
4645

4746
build-rust-component-examples target=default-target: (compile-wit)
4847
# 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
4948
# 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
5049
rustup target add wasm32-unknown-unknown
5150
cd ./src/component_sample && cargo component build --target wasm32-unknown-unknown --profile={{ if target == "debug" {"dev"} else { target } }}
5251
cargo run -p hyperlight-wasm-aot compile --component ./src/component_sample/target/wasm32-unknown-unknown/{{ target }}/component_sample.wasm ./x64/{{ target }}/component_sample.aot
53-
cp ./x64/{{ target }}/component_sample.aot ./x64/{{ target }}/component_sample.wasm
5452

5553
check target=default-target:
5654
cargo check --profile={{ if target == "debug" {"dev"} else { target } }}

src/hyperlight_wasm/benches/benchmarks.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ fn get_time_since_boot_microsecond() -> Result<i64> {
2828
fn wasm_guest_call_benchmark(c: &mut Criterion) {
2929
let mut group = c.benchmark_group("wasm_guest_functions");
3030

31-
let bench_guest_function = |b: &mut Bencher<'_>, ext| {
32-
let mut loaded_wasm_sandbox = get_loaded_wasm_sandbox(ext);
31+
let bench_guest_function = |b: &mut Bencher<'_>| {
32+
let mut loaded_wasm_sandbox = get_loaded_wasm_sandbox();
3333

3434
b.iter(|| {
3535
loaded_wasm_sandbox
@@ -38,12 +38,8 @@ fn wasm_guest_call_benchmark(c: &mut Criterion) {
3838
});
3939
};
4040

41-
group.bench_function("wasm_guest_call", |b: &mut Bencher<'_>| {
42-
bench_guest_function(b, "wasm");
43-
});
44-
4541
group.bench_function("wasm_guest_call_aot", |b: &mut Bencher<'_>| {
46-
bench_guest_function(b, "aot");
42+
bench_guest_function(b);
4743
});
4844

4945
group.finish();
@@ -52,7 +48,7 @@ fn wasm_guest_call_benchmark(c: &mut Criterion) {
5248
fn wasm_sandbox_benchmark(c: &mut Criterion) {
5349
let mut group = c.benchmark_group("wasm_sandboxes");
5450
let create_wasm_sandbox = || {
55-
get_loaded_wasm_sandbox("wasm");
51+
get_loaded_wasm_sandbox();
5652
};
5753

5854
group.bench_function("create_sandbox", |b| {
@@ -66,7 +62,7 @@ fn wasm_sandbox_benchmark(c: &mut Criterion) {
6662
group.finish();
6763
}
6864

69-
fn get_loaded_wasm_sandbox(ext: &str) -> LoadedWasmSandbox {
65+
fn get_loaded_wasm_sandbox() -> LoadedWasmSandbox {
7066
let mut sandbox = SandboxBuilder::new().build().unwrap();
7167

7268
sandbox
@@ -79,7 +75,7 @@ fn get_loaded_wasm_sandbox(ext: &str) -> LoadedWasmSandbox {
7975
let wasm_sandbox = sandbox.load_runtime().unwrap();
8076

8177
wasm_sandbox
82-
.load_module(format!("../../x64/release/RunWasm.{ext}",))
78+
.load_module("../../x64/release/RunWasm.aot")
8379
.unwrap()
8480
}
8581

src/hyperlight_wasm/benches/benchmarks_components.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ impl bindings::example::runcomponent::RuncomponentImports for State {
4646
fn wasm_component_guest_call_benchmark(c: &mut Criterion) {
4747
let mut group = c.benchmark_group("wasm_component_guest_functions");
4848

49-
let bench_guest_function = |b: &mut Bencher<'_>, ext| {
50-
let (sb, rt) = get_loaded_wasm_sandbox(ext);
49+
let bench_guest_function = |b: &mut Bencher<'_>| {
50+
let (sb, rt) = get_loaded_wasm_sandbox();
5151
let mut wrapped = bindings::RuncomponentSandbox { sb, rt };
5252
let instance = bindings::example::runcomponent::RuncomponentExports::guest(&mut wrapped);
5353

@@ -56,12 +56,8 @@ fn wasm_component_guest_call_benchmark(c: &mut Criterion) {
5656
});
5757
};
5858

59-
group.bench_function("wasm_guest_call", |b: &mut Bencher<'_>| {
60-
bench_guest_function(b, "wasm");
61-
});
62-
6359
group.bench_function("wasm_guest_call_aot", |b: &mut Bencher<'_>| {
64-
bench_guest_function(b, "aot");
60+
bench_guest_function(b);
6561
});
6662

6763
group.finish();
@@ -70,7 +66,7 @@ fn wasm_component_guest_call_benchmark(c: &mut Criterion) {
7066
fn wasm_component_sandbox_benchmark(c: &mut Criterion) {
7167
let mut group = c.benchmark_group("wasm_component_sandboxes");
7268
let create_wasm_sandbox = || {
73-
get_loaded_wasm_sandbox("wasm");
69+
get_loaded_wasm_sandbox();
7470
};
7571

7672
group.bench_function("create_sandbox", |b| {
@@ -84,9 +80,7 @@ fn wasm_component_sandbox_benchmark(c: &mut Criterion) {
8480
group.finish();
8581
}
8682

87-
fn get_loaded_wasm_sandbox(
88-
ext: &str,
89-
) -> (
83+
fn get_loaded_wasm_sandbox() -> (
9084
LoadedWasmSandbox,
9185
Arc<Mutex<bindings::RuncomponentResources<State>>>,
9286
) {
@@ -97,7 +91,7 @@ fn get_loaded_wasm_sandbox(
9791
let sb = sandbox.load_runtime().unwrap();
9892

9993
let sb = sb
100-
.load_module(format!("../../x64/release/runcomponent.{ext}",))
94+
.load_module("../../x64/release/runcomponent.aot")
10195
.unwrap();
10296
(sb, rt)
10397
}

src/hyperlight_wasm/examples/component_example/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn main() {
5555

5656
let sb = sb.load_runtime().unwrap();
5757

58-
let mod_path = get_wasm_module_path("component_sample.wasm").unwrap();
58+
let mod_path = get_wasm_module_path("component_sample.aot").unwrap();
5959
let sb = sb.load_module(mod_path).unwrap();
6060

6161
let mut wrapped = bindings::ExampleSandbox { sb, rt };

src/hyperlight_wasm/examples/helloworld/main.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,12 @@ fn get_time_since_boot_microsecond() -> Result<i64> {
2626
}
2727

2828
fn main() -> Result<()> {
29-
let tests = vec![
30-
(
31-
"HelloWorld.wasm",
32-
"HelloWorld",
33-
"Message from Rust Example to Wasm Function".to_string(),
34-
),
29+
let tests = [
3530
(
3631
"HelloWorld.aot",
3732
"HelloWorld",
3833
"Message from Rust Example to Wasm Function".to_string(),
3934
),
40-
(
41-
"RunWasm.wasm",
42-
"Echo",
43-
"Message from Rust Example to Wasm Function".to_string(),
44-
),
4535
(
4636
"RunWasm.aot",
4737
"Echo",

src/hyperlight_wasm/examples/hostfuncs/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn main() {
3939
let wasm_sandbox = proto_wasm_sandbox.load_runtime().unwrap();
4040

4141
let mut loaded_wasm_sandbox = {
42-
let mod_path = get_wasm_module_path("rust_wasm_samples.wasm").unwrap();
42+
let mod_path = get_wasm_module_path("rust_wasm_samples.aot").unwrap();
4343
wasm_sandbox.load_module(mod_path)
4444
}
4545
.unwrap();

src/hyperlight_wasm/examples/metrics/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn main() -> Result<()> {
4141
let wasm_sandbox = wasm_sandbox.load_runtime()?;
4242

4343
let mut loaded_wasm_sandbox =
44-
wasm_sandbox.load_module(get_wasm_module_path("rust_wasm_samples.wasm")?)?;
44+
wasm_sandbox.load_module(get_wasm_module_path("rust_wasm_samples.aot")?)?;
4545

4646
loaded_wasm_sandbox
4747
.call_guest_function::<i32>("add", (5i32, 10i32))

src/hyperlight_wasm/examples/rust_wasm_examples/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn main() -> Result<()> {
4646
proto_wasm_sandbox.register("TestHostFunc", host_func)?;
4747

4848
let wasm_sandbox = proto_wasm_sandbox.load_runtime()?;
49-
let mod_path = get_wasm_module_path("rust_wasm_samples.wasm")?;
49+
let mod_path = get_wasm_module_path("rust_wasm_samples.aot")?;
5050

5151
// Load the Wasm module into the sandbox
5252
let mut loaded_wasm_sandbox = wasm_sandbox.load_module(mod_path)?;

src/hyperlight_wasm/scripts/build-wasm-examples.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ if [ -f "/.dockerenv" ] || grep -q docker /proc/1/cgroup; then
1818
# Build the wasm file with wasi-libc for wasmtime
1919
/opt/wasi-sdk/bin/clang -flto -ffunction-sections -mexec-model=reactor -O3 -z stack-size=4096 -Wl,--initial-memory=65536 -Wl,--export=__data_end -Wl,--export=__heap_base,--export=malloc,--export=free,--export=__wasm_call_ctors -Wl,--strip-all,--no-entry -Wl,--allow-undefined -Wl,--gc-sections -o ${OUTPUT_DIR}/${FILENAME%.*}-wasi-libc.wasm ${FILENAME}
2020

21-
# Build AOT for Wasmtime; note that Wasmtime does not support
22-
# interpreting, so its wasm binary is secretly an AOT binary.
2321
cargo run -p hyperlight-wasm-aot compile ${OUTPUT_DIR}/${FILENAME%.*}-wasi-libc.wasm ${OUTPUT_DIR}/${FILENAME%.*}.aot
24-
cp ${OUTPUT_DIR}/${FILENAME%.*}.aot ${OUTPUT_DIR}/${FILENAME%.*}.wasm
2522
done
2623

2724
for WIT_FILE in ${PWD}/components/*.wit; do
@@ -43,7 +40,6 @@ if [ -f "/.dockerenv" ] || grep -q docker /proc/1/cgroup; then
4340

4441
# Build AOT for Wasmtime
4542
cargo run -p hyperlight-wasm-aot compile --component ${OUTPUT_DIR}/${COMPONENT_NAME}-p2.wasm ${OUTPUT_DIR}/${COMPONENT_NAME}.aot
46-
cp ${OUTPUT_DIR}/${COMPONENT_NAME}.aot ${OUTPUT_DIR}/${COMPONENT_NAME}.wasm
4743
done
4844

4945
else
@@ -62,10 +58,7 @@ else
6258
# Build the wasm file with wasi-libc for wasmtime
6359
docker run --rm -i -v "${PWD}:/tmp/host" -v "${OUTPUT_DIR}:/tmp/output/" wasm-clang-builder:latest /opt/wasi-sdk/bin/clang -flto -ffunction-sections -mexec-model=reactor -O3 -z stack-size=4096 -Wl,--initial-memory=65536 -Wl,--export=__data_end -Wl,--export=__heap_base,--export=malloc,--export=free,--export=__wasm_call_ctors -Wl,--strip-all,--no-entry -Wl,--allow-undefined -Wl,--gc-sections -o /tmp/output/${FILENAME%.*}-wasi-libc.wasm /tmp/host/${FILENAME}
6460

65-
# Build AOT for Wasmtime; note that Wasmtime does not support
66-
# interpreting, so its wasm binary is secretly an AOT binary.
6761
cargo run -p hyperlight-wasm-aot compile ${OUTPUT_DIR}/${FILENAME%.*}-wasi-libc.wasm ${OUTPUT_DIR}/${FILENAME%.*}.aot
68-
cp ${OUTPUT_DIR}/${FILENAME%.*}.aot ${OUTPUT_DIR}/${FILENAME%.*}.wasm
6962
done
7063

7164
echo Building components
@@ -89,7 +82,6 @@ else
8982

9083
# Build AOT for Wasmtime
9184
cargo run -p hyperlight-wasm-aot compile --component ${OUTPUT_DIR}/${COMPONENT_NAME}-p2.wasm ${OUTPUT_DIR}/${COMPONENT_NAME}.aot
92-
cp ${OUTPUT_DIR}/${COMPONENT_NAME}.aot ${OUTPUT_DIR}/${COMPONENT_NAME}.wasm
9385
done
9486
fi
9587

0 commit comments

Comments
 (0)