github.com/ncruces/go-sqlite3@v0.15.1-0.20240520133447-53eef1510ff0/embed/build.sh (about) 1 #!/usr/bin/env bash 2 set -euo pipefail 3 4 cd -P -- "$(dirname -- "$0")" 5 6 ROOT=../ 7 BINARYEN="$ROOT/tools/binaryen-version_117/bin" 8 WASI_SDK="$ROOT/tools/wasi-sdk-22.0/bin" 9 10 "$WASI_SDK/clang" --target=wasm32-wasi -std=c17 -flto -g0 -O2 \ 11 -Wall -Wextra -Wno-unused-parameter -Wno-unused-function \ 12 -o sqlite3.wasm "$ROOT/sqlite3/main.c" \ 13 -I"$ROOT/sqlite3" \ 14 -mexec-model=reactor \ 15 -msimd128 -mmutable-globals \ 16 -mbulk-memory -mreference-types \ 17 -mnontrapping-fptoint -msign-ext \ 18 -fno-stack-protector -fno-stack-clash-protection \ 19 -Wl,--initial-memory=327680 \ 20 -Wl,--stack-first \ 21 -Wl,--import-undefined \ 22 -D_HAVE_SQLITE_CONFIG_H \ 23 -DSQLITE_CUSTOM_INCLUDE=sqlite_opt.h \ 24 $(awk '{print "-Wl,--export="$0}' exports.txt) 25 26 trap 'rm -f sqlite3.tmp' EXIT 27 "$BINARYEN/wasm-ctor-eval" -g -c _initialize sqlite3.wasm -o sqlite3.tmp 28 "$BINARYEN/wasm-opt" -g --strip --strip-producers -c -O3 \ 29 sqlite3.tmp -o sqlite3.wasm \ 30 --enable-simd --enable-mutable-globals --enable-multivalue \ 31 --enable-bulk-memory --enable-reference-types \ 32 --enable-nontrapping-float-to-int --enable-sign-ext