2024-06-17 23:44:37 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
cd -P -- "$(dirname -- "$0")"
|
|
|
|
|
|
|
|
|
|
ROOT=../../../
|
2024-07-20 00:43:34 +01:00
|
|
|
BINARYEN="$ROOT/tools/binaryen/bin"
|
|
|
|
|
WASI_SDK="$ROOT/tools/wasi-sdk/bin"
|
2024-06-17 23:44:37 +01:00
|
|
|
|
2024-08-09 12:45:19 +01:00
|
|
|
trap 'rm -f sql3parse_table.tmp' EXIT
|
|
|
|
|
|
2024-08-03 00:13:06 +01:00
|
|
|
"$WASI_SDK/clang" --target=wasm32-wasi -std=c23 -g0 -Oz \
|
2025-04-07 12:49:01 +01:00
|
|
|
-Wall -Wextra -Wno-unused-parameter -Wno-unused-function \
|
|
|
|
|
-o sql3parse_table.wasm main.c \
|
2025-04-17 13:55:44 +01:00
|
|
|
-I"$ROOT/sqlite3/libc" -I"$ROOT/sqlite3" \
|
2024-06-17 23:44:37 +01:00
|
|
|
-mexec-model=reactor \
|
2025-05-13 14:27:26 +01:00
|
|
|
-mmutable-globals -mnontrapping-fptoint \
|
|
|
|
|
-msimd128 -mbulk-memory -msign-ext \
|
|
|
|
|
-mreference-types -mmultivalue \
|
2025-07-29 16:48:33 +01:00
|
|
|
-mno-extended-const \
|
|
|
|
|
-fno-stack-protector \
|
2024-06-17 23:44:37 +01:00
|
|
|
-Wl,--stack-first \
|
|
|
|
|
-Wl,--import-undefined \
|
2024-07-03 14:06:07 +01:00
|
|
|
-Wl,--export=sql3parse_table
|
2024-06-17 23:44:37 +01:00
|
|
|
|
2024-07-03 14:06:07 +01:00
|
|
|
"$BINARYEN/wasm-ctor-eval" -c _initialize sql3parse_table.wasm -o sql3parse_table.tmp
|
2025-09-08 12:23:58 +01:00
|
|
|
"$BINARYEN/wasm-opt" sql3parse_table.tmp -o sql3parse_table.wasm \
|
|
|
|
|
--low-memory-unused --gufa --generate-global-effects --converge -Oz \
|
2025-05-13 14:27:26 +01:00
|
|
|
--enable-mutable-globals --enable-nontrapping-float-to-int \
|
|
|
|
|
--enable-simd --enable-bulk-memory --enable-sign-ext \
|
2025-09-08 12:23:58 +01:00
|
|
|
--enable-reference-types --enable-multivalue \
|
|
|
|
|
--strip --strip-debug --strip-producers
|