Skip to content

Commit 76d6f58

Browse files
committed
Fix building debug examples
Signed-off-by: James Sturtevant <[email protected]>
1 parent 4f345d9 commit 76d6f58

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ build-wasm-examples target=default-target features="": (compile-wit)
4444
build-rust-wasm-examples target=default-target features="": (mkdir-redist target)
4545
rustup target add wasm32-unknown-unknown
4646
cd ./src/rust_wasm_samples && cargo build --target wasm32-unknown-unknown --profile={{ if target == "debug" {"dev"} else { target } }}
47-
cargo run {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--features " + features } }} -p hyperlight-wasm-aot compile ./src/rust_wasm_samples/target/wasm32-unknown-unknown/{{ target }}/rust_wasm_samples.wasm ./x64/{{ target }}/rust_wasm_samples.aot
47+
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
4848

4949
build-rust-component-examples target=default-target features="": (compile-wit)
5050
# 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
5151
# 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
5252
rustup target add wasm32-unknown-unknown
5353
cd ./src/component_sample && cargo component build --target wasm32-unknown-unknown --profile={{ if target == "debug" {"dev"} else { target } }}
54-
cargo run {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--features " + features } }} -p hyperlight-wasm-aot compile --component ./src/component_sample/target/wasm32-unknown-unknown/{{ target }}/component_sample.wasm ./x64/{{ target }}/component_sample.aot
54+
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
5555

5656
check target=default-target:
5757
cargo check --profile={{ if target == "debug" {"dev"} else { target } }}

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ else
2424
OPT_FLAGS="-O3"
2525
fi
2626

27+
# Set AOT debug flags if gdb feature is enabled
28+
if [[ "$FEATURES" == *"gdb"* ]]; then
29+
AOT_DEBUG_FLAGS="--debug"
30+
else
31+
AOT_DEBUG_FLAGS=""
32+
fi
33+
2734
if [ -f "/.dockerenv" ] || grep -q docker /proc/1/cgroup; then
2835
# running in a container so use the installed wasi-sdk as the devcontainer has this installed
2936
for FILENAME in $(find . -name '*.c' -not -path './components/*')
@@ -32,7 +39,7 @@ if [ -f "/.dockerenv" ] || grep -q docker /proc/1/cgroup; then
3239
# Build the wasm file with wasi-libc for wasmtime
3340
/opt/wasi-sdk/bin/clang ${DEBUG_FLAGS} -flto -ffunction-sections -mexec-model=reactor ${OPT_FLAGS} -z stack-size=4096 -Wl,--initial-memory=65536 -Wl,--export=__data_end -Wl,--export=__heap_base,--export=malloc,--export=free,--export=__wasm_call_ctors ${STRIP_FLAGS} -Wl,--no-entry -Wl,--allow-undefined -Wl,--gc-sections -o ${OUTPUT_DIR}/${FILENAME%.*}-wasi-libc.wasm ${FILENAME}
3441

35-
cargo run ${AOT_FEATURES} -p hyperlight-wasm-aot compile ${OUTPUT_DIR}/${FILENAME%.*}-wasi-libc.wasm ${OUTPUT_DIR}/${FILENAME%.*}.aot
42+
cargo run ${AOT_FEATURES} -p hyperlight-wasm-aot compile ${AOT_DEBUG_FLAGS} ${OUTPUT_DIR}/${FILENAME%.*}-wasi-libc.wasm ${OUTPUT_DIR}/${FILENAME%.*}.aot
3643
done
3744

3845
for WIT_FILE in ${PWD}/components/*.wit; do
@@ -53,7 +60,7 @@ if [ -f "/.dockerenv" ] || grep -q docker /proc/1/cgroup; then
5360
${PWD}/components/bindings/${COMPONENT_NAME}_component_type.o
5461

5562
# Build AOT for Wasmtime
56-
cargo run ${AOT_FEATURES} -p hyperlight-wasm-aot compile --component ${OUTPUT_DIR}/${COMPONENT_NAME}-p2.wasm ${OUTPUT_DIR}/${COMPONENT_NAME}.aot
63+
cargo run ${AOT_FEATURES} -p hyperlight-wasm-aot compile ${AOT_DEBUG_FLAGS} --component ${OUTPUT_DIR}/${COMPONENT_NAME}-p2.wasm ${OUTPUT_DIR}/${COMPONENT_NAME}.aot
5764
done
5865

5966
else
@@ -82,7 +89,7 @@ else
8289
-v "${OUTPUT_DIR_REAL}:${OUTPUT_DIR_REAL}" \
8390
wasm-clang-builder:latest /bin/bash -c "/opt/wasi-sdk/bin/clang ${DEBUG_FLAGS} -flto -ffunction-sections -mexec-model=reactor ${OPT_FLAGS} -z stack-size=4096 -Wl,--initial-memory=65536 -Wl,--export=__data_end -Wl,--export=__heap_base,--export=malloc,--export=free,--export=__wasm_call_ctors ${STRIP_FLAGS} -Wl,--no-entry -Wl,--allow-undefined -Wl,--gc-sections -o ${ABS_OUTPUT} ${ABS_INPUT}"
8491

85-
cargo run ${AOT_FEATURES} -p hyperlight-wasm-aot compile ${OUTPUT_WASM} ${OUTPUT_DIR}/${FILENAME%.*}.aot
92+
cargo run ${AOT_FEATURES} -p hyperlight-wasm-aot compile ${AOT_DEBUG_FLAGS} ${OUTPUT_WASM} ${OUTPUT_DIR}/${FILENAME%.*}.aot
8693
done
8794

8895
echo Building components
@@ -122,7 +129,7 @@ else
122129
${ABS_BINDINGS_TYPE_O}"
123130

124131
# Build AOT for Wasmtime
125-
cargo run ${AOT_FEATURES} -p hyperlight-wasm-aot compile --component ${OUTPUT_WASM} ${OUTPUT_DIR}/${COMPONENT_NAME}.aot
132+
cargo run ${AOT_FEATURES} -p hyperlight-wasm-aot compile ${AOT_DEBUG_FLAGS} --component ${OUTPUT_WASM} ${OUTPUT_DIR}/${COMPONENT_NAME}.aot
126133
done
127134
fi
128135

0 commit comments

Comments
 (0)