Skip to content

build: configure rusqlite for building on wasm [WPB-23771]#1926

Merged
coriolinus merged 4 commits intomainfrom
prgn/build/23771-add-rusqlite-sqlite3mc
Mar 10, 2026
Merged

build: configure rusqlite for building on wasm [WPB-23771]#1926
coriolinus merged 4 commits intomainfrom
prgn/build/23771-add-rusqlite-sqlite3mc

Conversation

@coriolinus
Copy link
Contributor

What's new in this PR

Based on https://github.com/coriolinus/rusqlite-experiment/blob/main/ffi/Cargo.toml we have set up Sqlite to build in all target environments in the keystore.


PR Submission Checklist for internal contributors
  • The PR Title
    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@coriolinus coriolinus requested a review from a team March 10, 2026 10:09
Copy link
Contributor

@fewerner fewerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@coriolinus
Copy link
Contributor Author

coriolinus commented Mar 10, 2026

Looks like it's currently failing on CI because rusqlite@0.37 depends on openssl-sys, where rusqlite@0.38 does not. And we can't straightforwardly upgrade the rusqlite version, because we also depend on refinery, and refinery is very particular about the rusqlite version that it builds with. Specifically, refinery only gained support for rusqlite@0.38 a month ago, and that version has not yet been released. (Note: rust-db/refinery#417)

How did this work in our demo? Simple, we didn't build refinery there.

Looks like the path to victory here is to upgrade the refinery version to current main, at least for the moment.

It's harder to understand when individual dependencies get full sub-tables,
so use inline tables for each of them, such that there is one relevant
dependency table for each cfg setup.
Rusqlite and refinery get compiled unconditionally, but we only
include sqlcipher in non-os-unknown (i.e. non-wasm) builds.
For os-unknown (wasm) builds, we instead include `sqlite-wasm-rs`
and `sqlite-wasm-vfs` and the `sqlite3mc` feature.
This necessitates depending on an unreleased revision of
`refinery`, unfortunately.
In v0.38, rusqlite fixed a logical problem: casting values to/from
unsigned 64-bit values was sometimes causing runtime errors, because
internally sqlite only knows about signed 64-bit integers.

The problem: rusqlite/rusqlite#1722
The fix: rusqlite/rusqlite#1732

This was a problem for us because we use u64s to represent timestamps
in the keystore.

This commit chooses to just add the feature flag which reenables
the old behavior. We're not going to be maintaining this code
anymore once the potential to overflow an i64 with a unix timestamp
is a reasonable possibility, and we're not using that type in other
contexts, so we should be fine.

I did consider the alternative of changing the underlying type
from u64 to i64. However, that would have meant a cascading series
of pointless changes all the way up to the ffi layer, and it just
did not seem worth it. So I rejected that for now.
@coriolinus coriolinus force-pushed the prgn/build/23771-add-rusqlite-sqlite3mc branch from a548e87 to b013e63 Compare March 10, 2026 16:31
@coriolinus coriolinus merged commit b013e63 into main Mar 10, 2026
31 checks passed
@coriolinus coriolinus deleted the prgn/build/23771-add-rusqlite-sqlite3mc branch March 10, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants