28 lines
847 B
Bash
Executable file
28 lines
847 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
declare -a EXPORT_FLAGS
|
|
while read -r -d, function; do
|
|
EXPORT_FLAGS+=("-Wl,--export=${function:1:-1}")
|
|
done < lib/src/wasm/stdlib-symbols.txt
|
|
|
|
target/wasi-sdk-21.0/bin/clang-17 \
|
|
-o stdlib.wasm \
|
|
-Os \
|
|
-fPIC \
|
|
-Wl,--no-entry \
|
|
-Wl,--stack-first \
|
|
-Wl,-z -Wl,stack-size=65536 \
|
|
-Wl,--import-undefined \
|
|
-Wl,--import-memory \
|
|
-Wl,--import-table \
|
|
-Wl,--strip-debug \
|
|
-Wl,--export=reset_heap \
|
|
-Wl,--export=__wasm_call_ctors \
|
|
-Wl,--export=__stack_pointer \
|
|
"${EXPORT_FLAGS[@]}" \
|
|
lib/src/wasm/stdlib.c
|
|
|
|
xxd -C -i stdlib.wasm > lib/src/wasm/wasm-stdlib.h
|
|
mv stdlib.wasm target/
|