Skip to content

fix(release): avoid shadowing bundled static C libs in Linux zigbuild - #7380

Merged
me2seeks merged 1 commit into
mainfrom
fix/linux-zigbuild-sqlite-shadowing
Nov 27, 2026
Merged

me2seeks merged 1 commit into
mainfrom
fix/linux-zigbuild-sqlite-shadowing

Conversation

@M4n5ter

@M4n5ter M4n5ter commented Nov 27, 2026

Copy link
Copy Markdown
Member

Root Cause

Nightly compat-gate failed on all 4 historical time capsules (Host ready: "original Host exited before ready"), while compat-post-merge (Linux debug) and macOS dist builds passed on the exact same commit.

Inspecting the Linux dist binary from the failing run showed:

  • host.stderr.log: unable to delete/modify user-function due to active statements during migration 61 (populate_all_fts_terms -> c.remove_function("maka_v59_recall_grams", 1)).
  • Embedded SQLite version in the Linux dist binary was 3.46.1 (COMPILER=gcc-15.2.0) instead of bundled libsqlite3-sys v0.40.0 (3.54.1).
  • linuxSystemLibraryRustflags in scripts/rust/build-cli.mjs injected -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib into CARGO_TARGET_*_RUSTFLAGS. Because RUSTFLAGS -L native= precedes crate build-script OUT_DIR search paths during both rustc .rlib bundling (-l static=sqlite3) and final linking (-l static:-bundle=...), Ubuntu's host libsqlite3.a (3.46.1) silently shadowed bundled libsqlite3-sys (3.54.1).
  • In SQLite 3.46.1, FTS5 fts5UpdateMethod did not close its cached p->pReader sqlite3_blob handle on exit (fixed in newer SQLite), leaving db->nVdbeActive == 1 inside the migration savepoint when remove_function ran.

Changes

  1. scripts/rust/build-cli.mjs + scripts/rust/build-cli.test.mjs: Replace -L native=<dir> with -C link-arg=-L<dir> in linuxSystemLibraryRustflags. -C link-arg=-L<dir> is excluded from rustc's .rlib archive search and placed after crate -L <OUT_DIR> arguments at final link time, so bundled static -sys archives cannot be shadowed while dynamic system libraries (GTK4/X11/Vulkan) still resolve.
  2. platform/event-log/src/connection.rs: Reject a linked SQLite runtime older than compiled libsqlite3-sys headers on connection open (rusqlite::version_number() < SQLITE_VERSION_NUMBER), so release smoke tests (maka code --root ...) catch any future SQLite shadowing immediately during the build job.
  3. products/maka/cli/tests/support/host.rs: When Host::ready() observes EOF before ready, reap the child to include its ExitStatus (exit code / signal) and append the tail of host.stderr.log so startup failures are directly diagnosable in CI logs.

Verification

  • Minimal two-crate repro on Linux x86_64 verified -L native=<sys> shadowed both static= and static:-bundle= archives, while -C link-arg=-L<sys> linked bundled archives and resolved dylib= from <sys>.
  • node --test scripts/rust/build-cli.test.mjs (5/5 pass)
  • npx --no-install biome check scripts/rust/build-cli.mjs scripts/rust/build-cli.test.mjs
  • cargo test --locked -p maka-event-log --lib connection (7/7 pass)
  • cargo clippy --no-deps --locked -p maka-event-log -p maka-cli --lib --bins -- -D warnings
  • cargo test --locked -p maka-cli --test upgrade_compat --no-run
  • cargo fmt --manifest-path Cargo.toml -p maka-event-log -p maka-cli -- --check
  • node scripts/ci.mjs check migrations
  • node scripts/asf-license-headers.mjs check

Passing host library directories via -L native=/usr/lib/<multiarch> in CARGO_TARGET_*_RUSTFLAGS puts host directories ahead of crate OUT_DIR search paths during rustc rlib archive bundling and final linking. On Ubuntu 26.04 runners, this silently linked the host GCC-built libsqlite3.a (3.46.1) instead of bundled libsqlite3-sys (3.54.1), breaking Nightly compat-gate migration 61 (SQLite 3.46.1 FTS5 leaves p->pReader open inside a savepoint, causing remove_function to fail with SQLITE_BUSY).

Pass host library dirs via -C link-arg=-L<dir> so system .so libraries still resolve at final link time without entering rustc's static archive search path ahead of crate OUT_DIRs. Also verify the linked SQLite runtime version against compiled headers on database open (so release smoke tests catch shadowing immediately) and include child exit status plus host.stderr.log tail in test Host::ready() startup failures.
@github-actions github-actions Bot added the effort/M Under 500 readable lines label Nov 27, 2026
@me2seeks

me2seeks commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

I independently reproduced the failure in WSL using the Linux x64 archive from nightly 46012434774 and capsule-first-nightly.tar.gz. The packaged Host exits before emitting ready, with unable to delete/modify user-function due to active statements in host.stderr.log. The binary contains SQLite 3.46.1 and COMPILER=gcc-15.2.0, consistent with the system archive shadowing the bundled one.

The history also lines up: #7169 introduced the native search path, and the FTS migration from #7287 exposed it on cold upgrades. #7375 fixed the separate v54 queue migration failure; its post-merge debug replay passed, while the next packaged nightly still failed on all four historical capsules.

@me2seeks
me2seeks merged commit 1bffa09 into main Nov 27, 2026
2 checks passed
@me2seeks
me2seeks deleted the fix/linux-zigbuild-sqlite-shadowing branch November 27, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants