Add spatial support for Wasm#471
Open
georgestagg wants to merge 11 commits into
Open
Conversation
georgestagg
commented
Jun 11, 2026
| @@ -0,0 +1,474 @@ | |||
| // Wasm Exception Handling proposal types | |||
Collaborator
Author
There was a problem hiding this comment.
This file contains our Wasm dynamic linker and implementations of related runtime functions like dlopen(). A whole bunch of low level memory layout fiddling and symbol offset calculations...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for dynamically loadable extensions for sqlite under wasm. The
ggsql-wasmpackage gains a new functioninstallExtension(), which asynchronously downloads additional extensions as.wasmbinaries distributed alongside our current set of ggsql wasm files. With this, sqlite extensions are downloaded if (and only if) the user requests for them to be installed using this function.Behind the scenes the
.wasmextensions are loaded into the WebAssembly memory space, and we perform a dynamic linking step to hook them up with the sqlite wasm binary that's now been configured with a bunch of exports for linking to extensions (sqlite3_*, various built-in maths functions, additionalrust_sqlite_*support functions).Unfortunately, for this to work we need to fork and modify the
sqlite-rs-wasmpackage to enable loadable extensions. I don't think it will be difficult to maintain a fork, but it is an unfortunate pain point. If it get's too much, we can easily back this out and revert to upstreamsqlite-rs-wasm.I have put the fork here: https://github.com/ggsql-dev/sqlite-wasm-rs. I have not used the
posit-devorg for two reasons,To avoid rebuilding the spatialite extension in every CI run, I've setup the forked repo above to build and release it as a
.wasmbinary, here. The./build-wasm.shscript that runs the show from this side downloads and caches that binary in thetargetdirectory.Some other tweaks:
Switched from a custom bump allocator to a using the Rust global allocator in our wasm sysroot, fixing a stack corruption bug for large allocations. This would have bitten us eventually even without spatial support.
Updated the sqlite reader to support our spatial ggsql queries, including a new dialect function
sql_make_envelope.Tweaked how parquet files are registered under wasm, so that geometry columns are stored as WKB binary blobs, then converted into Arrow binary columns, as expected.
If
INSTALL spatialis detected in a ggsql code block in the Quarto docs, our runtime library will interpret that as a request to run the wasminstallExtension()function to install the spatialite extension for this page.Some examples added to the playground.
All said and done, with this we get spatial support in Wasm, and interactive docs:
Screen.Recording.2026-06-10.at.14.11.32.mov