building sqlite wasm
last updated: Oct 20, 2023
brew install emscripten
- clone sqlite:
https://github.com/sqlite/sqlite.git
cd sqlite
./configure
(to build the wasm version, you'll need to have built a makefile first)make fiddle
- Once that completes, you should have the wasm version of sqlite built, as well as the fiddle (available here). To run it, I went to
ext/wasm/fiddle
and ran devd withdevd -ol .
Now what I'd like to figure out is how to build that with extensions, or how to enable javascript extensions like in sql.js
The functions I want are available in sqlean/stats, let's figure out how to compile it:
make prepare-dist
make download-sqlite SQLITE_VERSION="3360000" SQLITE_RELEASE_YEAR=2021
make download-external SQLITE_BRANCH=3.36
- I stole those values from here
make compile-macos-arm64
- now there's
dist/arm64/stats.dylib
et al
- now there's
How sqlite-lines builds his sqlite-wasm-with-extensions is by including the sqlite amalgamation.
Of course, this is a yak-shave! So we need to get a particular version of emcc running in order to compile their code. Let's try using this page and see if we can't get version 3.1.5 installed. (Homebrew currently has 3.1.20 which throws an error)
git clone https://github.com/emscripten-core/emsdk.git && cd emsdk
./emsdk install 3.1.5
- that ran and succeeded and installed the tools to
./upstream/emscripten/
and./node
- that ran and succeeded and installed the tools to
source ./emsdk_env.sh
- this adds the directories above to the path
- et voila
$ emcc --version
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.5 (d33328b22db1aa62a51c50731e9645951a2038bc)
Backlinks: