Skip to content

Merge upstream SQLite 3.48.0#2243

Open
penberg wants to merge 555 commits into
mainfrom
update-sqlite-3.48.0
Open

Merge upstream SQLite 3.48.0#2243
penberg wants to merge 555 commits into
mainfrom
update-sqlite-3.48.0

Conversation

@penberg
Copy link
Copy Markdown
Collaborator

@penberg penberg commented May 28, 2026

No description provided.

stephan and others added 30 commits November 6, 2024 04:38
…ers (e.g. how to update autosetup). Start marking up the proj.tcl APIs with autosetup's doc markup so that they appear in the ./configure --reference output.

FossilOrigin-Name: aa6213767f0d7e63c753e33aadb95cbeb8e522c22f2fe1bbfa4df66bea6e3380
…he more glaring design decisions.

FossilOrigin-Name: c0940a822a63bff74585bd37401eca92f74ddf9fe95748d2474039ee9b2bd9b6
…oc own section.

FossilOrigin-Name: bf42b93cc7a4f8de2308fa4e5a798a62797bc95d95e4b0bd06035c74413fa828
FossilOrigin-Name: 406d9122b75990722ab79fdf42d4528d670645d8f778ca0b5a2a35fa1dc106c4
…h look like they need it. Minor doc updates.

FossilOrigin-Name: d4fbd34f7a4b0e6179cb06114d148fbc5d30b8dc8db0b764f4347dd50ff591ba
FossilOrigin-Name: 2919a61bd4f8cb4f53462d4807cbc04ac5f71dd437cd693538754cf3f17d00cc
FossilOrigin-Name: 0588cc5c2fad980aa67402f4fe959a499d711ff23903a521af1b1abc4586c802
FossilOrigin-Name: d3887895a33742fb1fc97235cf897d295b237a9fb5a84031826f9c1018106f18
…sed in forum:cea40371c5e34b09 | for post cea40371c5e34b09].

FossilOrigin-Name: 5495b12569c318d5020b4b5a625a392ef8e777b81c0200624fbbc2a6b5eddef9
…gurations.

FossilOrigin-Name: 9cc04331a01760189d88697233009dbe8a60eda589792ad01b56300499e9f54d
FossilOrigin-Name: edb842349320eda9550bdfcd5a327949c5512e02f4b993782587b2131a425746
…random

byte sequence generated by sqlite3_randomness(), which is different on
big-endian platforms than it is on little-endian platforms.

FossilOrigin-Name: 6216bfcb74273b7893735e265d3f04d1362fa625cd60cebccb866ce7d6c50e01
…TCL to 0. We can't build the TCL components on those. Problem reported in [forum:5106aee3a8|forum post 5106aee3a8].

FossilOrigin-Name: 04d2576b2e516fc5f5ba719d6bb01d25fd3b06b1c2d26acbec32bcdd65e9a01c
…that checks for .exe extensions on Windows.

FossilOrigin-Name: 052a1b4d7cb43b7f65028c41e9a7a17b533c834d8f620fbc7bc0adddb1fdb843
FossilOrigin-Name: f469356749b62b3ce4161b40ed105d60867a366a389efa583fe9607a13426803
…CL used for code generation, enable linenoise in jimsh. Remove some dead auto.def code.

FossilOrigin-Name: 0d558318172dddc8d5c5842625ddf09866ae09cac9cf28731be44db86b5e0fb1
FossilOrigin-Name: f5b6604716826b2057e969a8c0d099325b22eac42f1da65ec367671fc6625639
FossilOrigin-Name: 4749967e1b85675580eda2e92f4463c022e3ff929390a8f5b59f614f3975e158
…doc updates.

FossilOrigin-Name: 4455718e485a31100ce3eb4ac5aeb7437c667d7994c6d2abfb38ad8bd1976d6e
FossilOrigin-Name: 574515290058ddfaf39a4221fa0f7a99222c4b040dd455348550816b18492c20
FossilOrigin-Name: 6201b5707f8c895028f9c08cb4f83d33a16a91bf04ed3830ac51aa763d6b7205
…refix dir to it. If --with-tcl or --enable-tcl are explicitly passed in and tclConfig.sh is not found, fail fatally. When TCL is either explicitly disabled or default search for it fails non-fatally, be more explicit about which components are not available.

FossilOrigin-Name: c5389d39a90047683e80ae9081d5d10aaa95da00dfc8a133b4a1a6949a11620d
FossilOrigin-Name: bb5656bdc905947df205432e108ca6724393061a27028e23bf35b4bf48505d4f
…asi-sdk.

FossilOrigin-Name: 2a2419ef742c9f37c32be04d417337c1fa22503305d2df154fa38b2b69eae943
…atabase records.

FossilOrigin-Name: 108863ec7998e0a35569e3c6534b538f00d4ef87fdb316bd6a4a9a7a272bba47
… clear whether blindly setting the SONAME, which now differs from its historical value, will cause more grief than it solves. Add a (disabled) experiment which permits setting (or not) the SONAME to the legacy or current values. This change is up for further change as experimentation proves whether we truly need/want the SONAME. See discussion in/around [forum:0c6fc6f46b2cb3|forum post 0c6fc6f46b2cb3].

FossilOrigin-Name: d931456805e7d5c3379ca68b97a0a1d4ab1eb80c5e90c169cf43fc8239247d25
…imited form than the legacy build it (i.e. only to select targets rather than all targets). Rename make-side internal uses of CFLAGS to CFLAGS.env for consistency with the new LDFLAGS.env. See discussion in [forum:5fcbea40f3|forum thread 5fcbea40f3].

FossilOrigin-Name: a5e07e8063ad50f2cf46b6be568717adc9604bd6dbf926a526de43bda2996ad0
…ng them to be passed to configure but not to make. We cannot 100% enforce that because main.mk is not filtered by the configure script, so we instead add a level of indirection to make passing of LDFLAGS=... to make a no-op.

FossilOrigin-Name: d1af9f31831dc99a808b916df4d414943f5d56796c8342411ee4a57abfde85e2
…clsqlite3.

FossilOrigin-Name: bb3c6dc126896528328bb9f51a28a1d46d4549e687c93c16f2d164230c6b1684
…es not have a well-defined name and dependencies). Improve the deps for .tclenv.sh to avoid getting a stale tclsh when re-configuring with a different --with-tcl(sh).

FossilOrigin-Name: 1bd9de719b0944fdceec32103da3131a7d387820850ab03f652f813d840355b8
drh and others added 29 commits January 6, 2025 21:36
…out of

a read-only check-out.

FossilOrigin-Name: cb54f0063edd284996b225183b8e35d71ffcd3c0fb4f56a0e316181f1a186d46
…ce tree.

FossilOrigin-Name: f99a70eca2fd8a54be3a6629dabd62efc623488706eed5e5a1bd0be577ac1acb
FossilOrigin-Name: dd934f032fa6fc790a951006512e3ed76a5f2930858932918eafdbe3ceec4620
FossilOrigin-Name: 7d41885e85b0e2ef28bac34d663af07c35b21ee3e8b14481d2371f623bce681d
FossilOrigin-Name: 14b38ae6ab86a314a63ca9513850b43fcc670864f94d03a2706eff469980da88
install a full-featured SQLite and so that Tcl is build statically so that
there is no need to worry with LD_LIBRARY_PATH.

FossilOrigin-Name: c8972e652ebe62a8583904b5bc1d96b2d598222c037a714c8ff114ca84b52c7a
FossilOrigin-Name: 5872d7a0a7d4959562e1218bbba1115df8b292d980234273d0d38749edf19822
FossilOrigin-Name: 8a56e98d257e280d308b9fdc26e17e202f00a70fb9a780e30924e87a189fc7f4
…r able

to work with boolean values in both Tcl86 and Tcl90.

FossilOrigin-Name: 4e85343d6107a46682b549667410c296d7f4d17e3ac04ded7357afcbbfbe3e6d
FossilOrigin-Name: 32b8b078d16b8931afa56e587cf840412c65b68da0bc6fd6280ac773295116cf
…ation for

why the tcl library needs to be copied into the install directory.

FossilOrigin-Name: cff70c859fff37f886fd622b7335a73836ff8cf15e6cb7aabcff449a7e427fa8
No code changes.

FossilOrigin-Name: 5e6ede92afae77ce6023f3b294dc565651631c7976d898d800988f1b3ff2e83f
… removed.

FossilOrigin-Name: c0b691095ae72fc07530777ef6d23688fb4196ce2e0feff14fc3c597c572252d
FossilOrigin-Name: 6da37893f5b5729ea5fd632e8d98789e867488a67501d4a4dad92f8e7cb6bda0
…version to SECUREDELETE until flushing data to disk. This prevents problems that can occur if there is a rollback or statement rollback operation.

FossilOrigin-Name: c359e555ceafcaab2ae38074bc4f57cccdc5bc6080d17f82290c09b9e5dd80c2
…rectory

in the amalgamation-zip.
[forum:/forumpost/b8dd1941e1|Forum post b8dd1941e1].

FossilOrigin-Name: cef8e88bedf01dc47012ef1cb878b22117c9966e615edf5a69704486f9cfa56c
…A) caused removal of customized WASM func/argument conversion to siltently fail and (B) triggered a warning in the closure toolchain. Reported in [jaccwabyt ticket c5c296e85a7c01360820|https://fossil.wanderinghorse.net/r/jaccwabyt/info/c5c296e85a7c01360820].

FossilOrigin-Name: 99917a5bb04b5ad6ace95baf86d91e6ce098f9d3001de1a29d3d0b0b817acdce
FossilOrigin-Name: b93af6feb7c0c3af30a47810a7c0e77ce41c386fac164c64bb5871a6c153db7e
…ting

and working.

FossilOrigin-Name: c847973947de67579fab78a65ecfc90bf59fd5db0b7fa7a9c1abb1fc92213d01
…when

I upgraded to gcc-13.

FossilOrigin-Name: 3e2875dac27de1525d9c78f38ac5f1fc12fec7e1b43dbdf47798b128fae49084
…s matching the

type of pointers through which the functions are called.  Make adjustments to
extension functions and test procedures to work around this.  No changes to the
core.

FossilOrigin-Name: ed83b79100b4345235aec990303c4526874f0c2f8701160c4639a80633ebaf70
FossilOrigin-Name: 315079b150b47e013e2cde4985bc39d24e0f6f6c6e60f9383fb8ea4ea897c67a
FossilOrigin-Name: d2fe6b05f38d9d7cd78c5d252e99ac59f1aea071d669830c1ffe4e8966e84010
This merges the version-3.48.0 tag (942c958 "Version 3.48.0") of
upstream SQLite into libSQL. Conflicts were resolved with rename-following
(libsql vendors SQLite under libsql-sqlite3/, while upstream paths are at
the root), using a large merge.renameLimit so the ~2000 top-level ->
libsql-sqlite3/ moves are all detected:

    git -c merge.renameLimit=999999 -c diff.renameLimit=999999 \
        merge --no-commit version-3.48.0

Only files under libsql-sqlite3/ are changed by this merge. The
libsql-ffi/ bundled amalgamation and the SQLite3MultipleCiphers tree are
intentionally left untouched here; regenerating the bundle is a separate
step (cargo xtask build-bundled + scripts/update-sqlite-bundle.sh).

== Build system: autotools -> autosetup ==

The most invasive change in upstream 3.48.0 is the switch from autotools
to autosetup. Upstream removed configure.ac, aclocal.m4, install-sh,
ltmain.sh, sqlite_cfg.h.in, spec.template, Makefile.linux-gcc, and the
top-level config.guess / config.sub; replaced them with auto.def,
Makefile.linux-generic, and an autosetup/ tree (16 files including
jimsh0.c, the bundled JimTCL interpreter). libsql's old Makefile.in was a
1848-line autotools-generated file with many libsql-specific targets
(liblibsql.la, liblibsql_wasm, libsqlapi, testlibsql, rusttest,
rusttestwasm, libsql.pc, the OPT_WASM_RUNTIME switch). Upstream's new
Makefile.in is a 338-line thin wrapper that delegates almost everything
to a much-expanded main.mk.

The decision was to follow upstream and adopt autosetup. Concretely:

* Deleted: libsql-sqlite3/{aclocal.m4, configure.ac, install-sh,
  ltmain.sh, spec.template, sqlite_cfg.h.in, Makefile.linux-gcc,
  config.guess, config.sub}.
* Routed upstream's new top-level additions into libsql-sqlite3/ (git's
  rename detection could not pair them since libsql vendors under that
  subdir): auto.def, Makefile.linux-generic, autosetup/* including the
  autosetup-config.{guess,sub} rename targets.
* Replaced libsql-sqlite3/Makefile.in wholesale with upstream's autosetup
  port.

The libsql-specific Makefile targets (liblibsql.la, liblibsql_wasm, etc.)
were NOT re-ported into the new main.mk in this commit. The cargo-driven
build (libsql-ffi/build.rs) does not need them; restoring those targets
for direct in-tree use is left as a follow-up.

== Upstream removals (followed) ==

The following extensions and tests were deleted upstream in 3.48.0 and we
followed the removal:

* ext/async/* (async I/O extension)
* ext/userauth/* (user-authentication extension)
* ext/consio/console_io.{c,h} (refactored away; shell now uses
  sqlite3_fprintf() directly)
* src/test_async.c, test/async{,2,3,4,5}.test, test/userauth01.test,
  test/tkt-94c04eaadb.test
* vsixtest/ (VS extension test project, 18 files)

The libsql-local SQLITE_USER_AUTHENTICATION MSVC #warning workaround
(commit 23c1dd1) was explicitly meant to be moot once we passed
3.47.0; it is dropped here.

== Renames / path moves ==

* config.guess     -> autosetup/autosetup-config.guess
* config.sub       -> autosetup/autosetup-config.sub
* Makefile.linux-gcc -> Makefile.linux-generic

== Resolved content conflicts ==

src/sqliteInt.h (2 hunks)
  Dropped libsql's entire SQLITE_USER_AUTHENTICATION block - the MSVC
  #warning guard, sqlite3_userauth typedef/struct, UAUTH_* defines, and
  sqlite3UserAuth* prototypes - following upstream's removal of the
  extension. In struct sqlite3, dropped the sqlite3_userauth auth field
  but kept libsql's locally-added fields: libsql_wasm_ctx wasm
  (LIBSQL_ENABLE_WASM_RUNTIME), RefCountedWalManager *wal_manager
  (!SQLITE_OMIT_WAL), pCloseArg, and xCloseCallback.

src/pager.c (3 hunks)
  Dropped libsql's `#define isOpen(pFd) ((pFd)->pMethods!=0)` - upstream
  moved it to pager.h:100 in 3.48.0, where the auto-merge picked it up
  correctly. Kept libsql's pagerUseWal definition `((x)->wal!=0)` for the
  virtual-WAL pointer (vs upstream's `((x)->pWal!=0)`), plus all the
  SQLITE_OMIT_WAL no-op fallbacks. In sqlite3PagerDirectReadOk, took
  upstream's added `assert(pPager!=0)` / `assert(pPager->fd!=0)` and the
  Case-comment annotations, and kept libsql's `if(pPager->hasCodec)
  return 0;` check and libsql's virtual-WAL frame lookup
  `pPager->wal->methods.xFindFrame(pPager->wal->pData, pgno, &iRead)`.

src/wal.c (1 hunk in walTryBeginRead, plus 1 sympathy edit elsewhere)
  Took upstream's restructuring of the mxReadMark/mxI/mxFrame lookup -
  upstream wrapped those variables in an inner `{ ... }` scope, moved
  the `mxI==0` check inside that block, and made walEnableBlockingMs /
  walDisableBlocking calls unconditional (dropping libsql's prior
  #ifdef SQLITE_ENABLE_SETLK_TIMEOUT guards). To keep that compiling
  in non-SETLK_TIMEOUT builds, added `# define walEnableBlockingMs(pWal,
  ms) 0` to libsql's `#else` block at the no-op macro definitions,
  mirroring upstream's same addition there. libsql's local
  walLockWriter() no-op define in that block is preserved.

src/shell.c.in (1 hunk)
  Kept libsql's "libSQL version %s (based on SQLite version %s) %.19s\n"
  banner with libsql_libversion(), and dropped the now-undefined
  SHELL_CIO_CHAR_SET macro reference (consio is gone, so the macro is no
  longer defined anywhere).

doc/compile-for-windows.md (2 hunks)
  Took upstream verbatim - the new "(Optional): Install TCL development
  libraries" language and the TCL-9-only build instructions. libsql had
  no local additions worth preserving here.

libsql-sqlite3/Makefile.in
  Replaced wholesale with upstream's 338-line autosetup wrapper (see
  build-system section above). The libsql-specific targets are deferred.

LICENSE.md (root, not under libsql-sqlite3/)
  Git's rename detection conflated the libsql project-root MIT LICENSE.md
  ("Copyright 2023 the sqld authors") with the upstream SQLite
  LICENSE.md. Resolved by restoring the libsql MIT license at the repo
  root (taking ours) and routing upstream's 3.48.0 license-text update
  into libsql-sqlite3/LICENSE.md, which is the file actually tracking
  upstream's.

== Rename-misrouting fix ==

ext/misc/regexp.c exists twice in the libsql tree - once under
libsql-sqlite3/ext/misc/ and once under
libsql-ffi/bundled/SQLite3MultipleCiphers/src/ - byte-identical to the
merge base. Git's rename detection paired the base file with the
(alphabetically first) libsql-ffi copy, so upstream's 3.48.0
`re_free(ReCompiled*) -> re_free(void*)` signature change landed in the
cipher-bundle copy while the real libsql-sqlite3/ext/misc/regexp.c was
left at 3.47.0. Reverted the libsql-ffi copy to pre-merge HEAD (the
bundle is updated out-of-band) and overwrote libsql-sqlite3/ext/misc/
regexp.c with upstream 3.48.0's content (no libsql-local modifications
in this file).

This is the same class of bug the 3.47.0 merge had to correct for
tclsqlite.c / shathree.c / series.c / fileio.c.

== Post-merge fixes in main.mk ==

After adopting upstream's Makefile.in, two pre-existing gaps in libsql's
main.mk had to be filled for the autosetup-driven build to work
(neither bit the old autotools build because Makefile.in had its own
duplicate SRC list there):

* Fixed `$(TOP)/ext/udf/wasmtime_bindings.c` typo to `wasmedge_bindings.c`
  - this was a pre-existing typo; the actual file is wasmedge_bindings.c
  and the old Makefile.in had it right.
* Added libsql-specific sources to SRC so mksqlite3c.tcl can find them
  in tsrc/: src/page_header.h, src/vector{,Int,Index,IndexInt,diskann,
  vtab}.{c,h}, and the per-precision vectorfloat{1bit,8,16,32,64,b16}.c
  variants - 13 files. These had only ever been declared in the old
  Makefile.in, never propagated into main.mk.

== Validation ==

cd libsql-sqlite3 && ./configure && make produces sqlite3,
libsqlite3.so, libsqlite3.a, libtclsqlite3.so. Smoke tests:
  SELECT sqlite_version();                         -> 3.48.0
  vector32('[1,2,3]') / vector_extract() roundtrip -> [1,2,3]

The libsql-vs-upstream patch was extracted at both 3.47.0 and 3.48.0
and diffed: aside from one stylistic comment revert in pager.c (//
preserved), every semantic difference between the two patches corresponds
to upstream itself adopting code libsql used to add, or upstream removing
constructs libsql's local patches touched (userauth, SHELL_CIO_CHAR_SET).
No libsql local modifications were lost.
The vendored copy at libsql-ffi/bundled/SQLite3MultipleCiphers/ was at
upstream v1.8.1, which is based on SQLite ~3.44 and still ships the user-
authentication extension. After the 3.48.0 merge (bcd6013) the SQLite
amalgamation no longer defines sqlite3_userauth / UAUTH_* (SQLite 3.48.0
removed the extension entirely), so sqlite3mc's userauth.c stopped
compiling against it.

This refreshes the vendored copy to upstream v2.0.2 (de01ff8 "Prepare
release of version 2.0.2"), which is the sqlite3mc release that targets
SQLite 3.48.0. The libsql-local patches are reapplied on top.

== Broad upstream changelog 1.8.1 -> 2.0.2 ==

* Remove user authentication extension (d15fcab) - both userauth.c and
  sqlite3userauth.h deleted; sqlite3mc.{c,h} now unconditionally
  `#undef SQLITE_USER_AUTHENTICATION`; CMakeLists.txt drops the
  SQLITE_USER_AUTHENTICATION option and the userauth public header.
  This is the change that unblocks the 3.48.0 amalgamation.
* Add AEGIS cipher (src/aegis/ tree, src/cipher_aegis.c, AEGIS added to
  the CODEC_TYPE enum in CMakeLists.txt).
* Vendor argon2 in-tree (src/argon2/).
* Android compile flags: -march=armv8-a+crypto for arm64-v8a,
  -mvaes for x86_64.
* Drop SQLITE3MC_USE_RANDOM_FILL_MEMORY option.
* Adjust includes / preprocessor symbols to be amalgamation-friendly
  (3739865, b2253ef, c95b4e8).
* AES hardware detection adjustments (398558f).
* Codec initialization fix (d9767c6, the 2.0.2-final commit).
* General cleanup of AEGIS / ARM / AltiVec variants (51f8e00, 5577826).
* Bumped cmake_minimum_required to 3.24.0 in the upstream file; libsql
  patches it back to 3.18.0 (kept for broader CI compatibility).

== Reapplied libsql-local patches ==

src/cipher_config.c
  sqlite3mcFileControlPragma -> libsql_extra_pragma (different signature,
  no SQLITE_NOTFOUND fallthrough check; called directly from libsql's
  patched sqlite3.c).
src/cipher_wxaes256.c
  Added libsql_generate_aes256_key() helper (padded-password SHA-256
  iteration).
src/codec_algos.c
  Added libsql_generate_initial_vector() wrapper.
src/codecext.c
  Forward-decl libsql_db_has_codec(); after sqlite3mcSetIsEncrypted(),
  update cached db->aDb[].hasCodec / pPager->hasCodec.
src/sqlite3mc.c
  #include "sqlite3.c" instead of upstream's "sqlite3patched.c" (libsql
  uses the unpatched amalgamation directly).
src/sqlite3mc_vfs.c
  sqlite3mcPagerCodec -> libsql_pager_codec_impl (takes libsql_pghdr*,
  returns int rc, writes data via out-param).
  sqlite3mcPagerHasCodec -> libsql_db_has_codec (takes sqlite3_vfs* +
  zFilename instead of PagerMC*; called at connection-open time so the
  hasCodec check can be cached).
CMakeLists.txt
  cmake_minimum_required 3.24 -> 3.18.
  Add LIBSQL_ENABLE_WASM_RUNTIME option.
  Add libsql-specific compile defs in SQLITE3MC_BASE_DEFINITIONS:
  LIBSQL_ENABLE_WASM_RUNTIME, LIBSQL_EXTRA_PRAGMAS,
  LIBSQL_CUSTOM_PAGER_CODEC, LIBSQL_ENCRYPTION,
  SQLITE_ENABLE_{DBSTAT,DBPAGE,STMT}VTAB=1, SQLITE_DEFAULT_FOREIGN_KEYS=1,
  HAVE_CIPHER_AES_256_CBC=1 with all other ciphers forced =0.
  Skip -msse4.2 -maes on aarch64/arm64/armv7/arm (Linux/Darwin block,
  GNU else-branch, and an added Clang block that also excludes
  CMAKE_ANDROID_ARCH_ABI arm variants).

== Out of scope (separate commit) ==

The regenerated SQLite amalgamation (libsql-ffi/bundled/src/sqlite3.{c,h},
libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.{c,h}) and the
regenerated bindgen files (libsql-ffi/bundled/bindings/{bindgen,
session_bindgen}.rs) will be committed separately as the "update bundled
SQLite to 3.48.0" step. With this commit in place,
`./scripts/update-sqlite-bundle.sh` and `cargo build --features
multiple-ciphers` succeed.
Regenerate the bundled SQLite amalgamation and Rust bindings from the
3.48.0 libsql-sqlite3 source tree, produced by:

    ./scripts/update-sqlite-bundle.sh

which runs `LIBSQL_DEV=1 cargo build` to refresh bindgen.rs /
session_bindgen.rs, then `cargo xtask build-bundled` to regenerate the
canonical sqlite3.{c,h} in both bundled/src/ and
bundled/SQLite3MultipleCiphers/src/. That xtask is the same one CI
validates in .github/workflows/c-bindings.yml.

Together with the prior two commits (bcd6013 "Merge upstream SQLite
3.48.0" and 097ec79 "Bump bundled SQLite3MultipleCiphers from 1.8.1
to 2.0.2"), this completes the 3.48.0 update: the libsql tree, the
sqlite3mc vendored copy, and the bundled amalgamation are all aligned
on SQLite 3.48.0.

Files:
  libsql-ffi/bundled/src/sqlite3.{c,h}                       (3.47.0 -> 3.48.0)
  libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.{c,h} (3.47.0 -> 3.48.0)
  libsql-ffi/bundled/bindings/{bindgen,session_bindgen}.rs   (regenerated)
Adopting upstream 3.48.0's autosetup wholesale (commit bcd6013) lost
the libsql-specific targets the old autotools Makefile.in provided. CI
PR #2243 surfaced two:

* Makefile CI (./configure --enable-wasm-runtime-dynamic) failed with
  "Unknown option --wasm-runtime-dynamic". The flag was never wired into
  the new auto.def.
* Extensions Tests (`make libsql`) and the Wasm CI step (`make
  liblibsql_install`, `make rusttestwasm`) failed with "No rule to make
  target 'libsql'". All of those targets were Makefile.in-only and were
  not present in upstream's main.mk.

Restore them so the CI workflows in .github/workflows/sqlite3.yml and
.github/workflows/extensions-test.yml work again.

== auto.def ==

Adds two flags:
  --enable-wasm-runtime          -> defines OPT_WASM_RUNTIME = y
  --enable-wasm-runtime-dynamic  -> defines OPT_WASM_RUNTIME = d
otherwise OPT_WASM_RUNTIME defaults to n. Mirrors the y/d/n switch the
old Makefile.in used.

== Makefile.in ==

Reads @OPT_WASM_RUNTIME@ into the make variable OPT_WASM_RUNTIME and
includes the new libsql.mk after main.mk.

== libsql.mk (new) ==

libsql-specific targets, kept in a separate file so the upstream
Makefile.in / main.mk diff stays minimal:

* libsql$(T.exe): byte-identical copy of sqlite3$(T.exe).
* liblibsql.LIB / liblibsql.SO: copies of libsqlite3.LIB / libsqlite3.SO
  (the old build literally relinked LIBOBJ twice under two names; the
  copy here avoids paying for the second link).
* libsql.pc: generated from libsql.pc.in via sed (autotools used
  config.status for this; we do it inline).
* liblibsql_wasm: `cargo build --release --lib` in
  crates/wasmtime-bindings/. The cargo target dir is discovered via
  `cargo metadata` rather than hard-coded (the old Makefile.in's
  $(WBTOP)/../target/release/ assumption breaks if cargo workspaces
  resolve to a different target directory, e.g. when CARGO_TARGET_DIR
  is set).
* liblibsql_wasm_install, liblibsql_install, lib_install: install
  rules, gated on $(ENABLE_STATIC) / $(ENABLE_SHARED) to match
  main.mk's install-so / install-lib pattern.
* libsqlapi, testlibsql, rusttest, rusttestwasm: pass-through to
  cargo against crates/ and test/rust_suite/.

OPT_WASM_RUNTIME y vs d vs n drives OPT_WASM_RUNTIME_LIBRARY_TARGET /
OPT_STATIC_LIBLIBSQL_WASM exactly as the old Makefile.in did, so
liblibsql_install in --enable-wasm-runtime-dynamic mode pulls in
liblibsql_wasm_install.

Verified locally with --enable-wasm-runtime-dynamic:
  make libsql                              -> OK
  make liblibsql_install DESTDIR=/tmp/x    -> installs liblibsql.{a,so}
                                              and liblibsql_wasm.{a,so*}
  make test                                -> 0 errors out of 331057 tests
  make rusttestwasm                        -> 24 passed; 0 failed
  cd ext/crr && make loadable && make test -> all suites Success
@penberg penberg force-pushed the update-sqlite-3.48.0 branch from 6cf6c6a to 3c3a40d Compare May 28, 2026 13:15
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.

1 participant