From 301788a9962d1f1b69e335bb2c596beeea1bba19 Mon Sep 17 00:00:00 2001 From: Nucleic Date: Tue, 28 Jul 2026 21:35:20 -0700 Subject: [PATCH] Merge nucleic/humble-fern-egret-60xo into dev --- build.ps1 | 9 ++++++--- .../arm64-windows-static-md-nucleic.cmake | 6 ++++++ .../x64-windows-static-md-nucleic.cmake | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 vcpkg-triplets/arm64-windows-static-md-nucleic.cmake create mode 100644 vcpkg-triplets/x64-windows-static-md-nucleic.cmake diff --git a/build.ps1 b/build.ps1 index 4232f93..c0de889 100644 --- a/build.ps1 +++ b/build.ps1 @@ -74,10 +74,13 @@ function Initialize-SQLite { if (-not $Triplet) { # -static-md links SQLite statically against the DYNAMIC CRT — matching what the # Swift toolchain uses, so the CRT agrees and there's no sqlite3.dll to place - # beside every test binary. + # beside every test binary. `-nucleic` is our overlay triplet (windows/vcpkg-triplets): + # same thing plus SQLITE_ENABLE_SNAPSHOT, which GRDB's system-SQLite path requires and + # the stock port compiles out. $arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'x64' } - $script:Triplet = "$arch-windows-static-md" + $script:Triplet = "$arch-windows-static-md-nucleic" } + $overlay = Join-Path $repo 'windows\vcpkg-triplets' # `%LOCALAPPDATA%\vcpkg` is NOT a candidate install root, and must never be a clone target: # that path is vcpkg's own per-user DATA directory (registries, downloads, and the @@ -121,7 +124,7 @@ function Initialize-SQLite { $prefix = Join-Path $root "installed\$Triplet" if (-not (Test-Path (Join-Path $prefix 'include\sqlite3.h'))) { Write-Step "Installing sqlite3:$Triplet (one time, a few minutes)" - & (Join-Path $root 'vcpkg.exe') install "sqlite3:$Triplet" | Out-Host + & (Join-Path $root 'vcpkg.exe') install "sqlite3:$Triplet" "--overlay-triplets=$overlay" | Out-Host if ($LASTEXITCODE -ne 0) { throw "vcpkg install sqlite3:$Triplet failed" } } diff --git a/vcpkg-triplets/arm64-windows-static-md-nucleic.cmake b/vcpkg-triplets/arm64-windows-static-md-nucleic.cmake new file mode 100644 index 0000000..d30673d --- /dev/null +++ b/vcpkg-triplets/arm64-windows-static-md-nucleic.cmake @@ -0,0 +1,6 @@ +# ARM64 twin of `x64-windows-static-md-nucleic.cmake` — see that file for why the define is here. +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_C_FLAGS "/DSQLITE_ENABLE_SNAPSHOT") +set(VCPKG_CXX_FLAGS "/DSQLITE_ENABLE_SNAPSHOT") diff --git a/vcpkg-triplets/x64-windows-static-md-nucleic.cmake b/vcpkg-triplets/x64-windows-static-md-nucleic.cmake new file mode 100644 index 0000000..536581d --- /dev/null +++ b/vcpkg-triplets/x64-windows-static-md-nucleic.cmake @@ -0,0 +1,17 @@ +# Stock `x64-windows-static-md` (SQLite linked statically against the DYNAMIC CRT — the CRT the +# Swift toolchain uses) PLUS `SQLITE_ENABLE_SNAPSHOT`. +# +# GRDB's system-SQLite path compiles `WALSnapshot.swift` and `DatabaseSnapshotPool.swift` +# unconditionally, i.e. it assumes the platform SQLite exposes `sqlite3_snapshot_*`. That holds +# for Apple's system SQLite and for typical Linux distro builds, but the vcpkg port ships stock +# defaults, where the snapshot API is compiled out — so the Windows link fails with four +# undefined symbols (`sqlite3_snapshot_open/get/free/cmp`) long after the library itself resolves. +# +# Used via `--overlay-triplets=windows/vcpkg-triplets` (windows/build.ps1, windows.yml). The +# `-nucleic` suffix keeps this tree from colliding with a stock `x64-windows-static-md` install +# in the same vcpkg root. +set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_C_FLAGS "/DSQLITE_ENABLE_SNAPSHOT") +set(VCPKG_CXX_FLAGS "/DSQLITE_ENABLE_SNAPSHOT")