Files
sqlite3/embed/build.sh

32 lines
1.1 KiB
Bash
Raw Permalink Normal View History

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=../
2024-02-28 12:48:05 +00:00
BINARYEN="$ROOT/tools/binaryen-version_117/bin"
2024-04-16 01:06:38 +01:00
WASI_SDK="$ROOT/tools/wasi-sdk-22.0/bin"
2023-04-14 00:09:40 +01:00
2024-01-16 15:18:14 +00:00
"$WASI_SDK/clang" --target=wasm32-wasi -std=c17 -flto -g0 -O2 \
2024-05-19 01:04:56 +01:00
-Wall -Wextra -Wno-unused-parameter -Wno-unused-function \
2023-04-14 00:09:40 +01:00
-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 \
2024-05-16 16:24:33 +01:00
-DSQLITE_CUSTOM_INCLUDE=sqlite_opt.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