2023-01-12 06:19:06 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-04-14 00:09:40 +01:00
|
|
|
set -euo pipefail
|
2023-01-11 14:58:20 +00:00
|
|
|
|
2023-01-12 06:19:06 +00:00
|
|
|
cd -P -- "$(dirname -- "$0")"
|
|
|
|
|
|
2023-04-14 00:09:40 +01:00
|
|
|
ROOT=../
|
2023-09-15 15:10:08 +01:00
|
|
|
BINARYEN="$ROOT/tools/binaryen-version_116/bin"
|
2023-04-14 00:09:40 +01:00
|
|
|
WASI_SDK="$ROOT/tools/wasi-sdk-20.0/bin"
|
|
|
|
|
|
|
|
|
|
"$WASI_SDK/clang" --target=wasm32-wasi -flto -g0 -O2 \
|
|
|
|
|
-o sqlite3.wasm "$ROOT/sqlite3/main.c" \
|
|
|
|
|
-I"$ROOT/sqlite3" \
|
|
|
|
|
-mexec-model=reactor \
|
2023-06-15 15:57:39 +01:00
|
|
|
-msimd128 -mmutable-globals \
|
2023-01-12 11:06:17 +00:00
|
|
|
-mbulk-memory -mreference-types \
|
|
|
|
|
-mnontrapping-fptoint -msign-ext \
|
2023-06-15 15:57:39 +01:00
|
|
|
-fno-stack-protector -fno-stack-clash-protection \
|
2023-04-14 00:09:40 +01:00
|
|
|
-Wl,--initial-memory=327680 \
|
|
|
|
|
-Wl,--stack-first \
|
|
|
|
|
-Wl,--import-undefined \
|
2023-06-24 02:18:56 +01:00
|
|
|
-D_HAVE_SQLITE_CONFIG_H \
|
2023-04-04 18:32:56 +01:00
|
|
|
$(awk '{print "-Wl,--export="$0}' exports.txt)
|
|
|
|
|
|
|
|
|
|
trap 'rm -f sqlite3.tmp' EXIT
|
2023-04-14 00:09:40 +01:00
|
|
|
"$BINARYEN/wasm-ctor-eval" -g -c _initialize sqlite3.wasm -o sqlite3.tmp
|
2023-11-28 01:10:24 +00:00
|
|
|
"$BINARYEN/wasm-opt" -g --strip --strip-producers -c -O3 \
|
2023-06-15 15:57:39 +01:00
|
|
|
sqlite3.tmp -o sqlite3.wasm \
|
|
|
|
|
--enable-simd --enable-mutable-globals --enable-multivalue \
|
2023-04-14 00:09:40 +01:00
|
|
|
--enable-bulk-memory --enable-reference-types \
|
|
|
|
|
--enable-nontrapping-float-to-int --enable-sign-ext
|