fix(build): link sqlite and libpq only when the backend needs them #32

Merged
pipeline-bot merged 1 commit from fix/conditional-backend-linkage into trunk 2026-08-13 15:52:25 +00:00
Owner

The shipped binaries carried DT_NEEDED for libpq5 and libsqlite3-0 while compiling the memory backend — symbols nothing could call. The deb honestly declared the matching depends, and its install test died on libpq5 [no choices] in every tester image, which is half of why zdns could not release (the other half, the release-path compile dispatch, was fixed in pipelines v0.1.638).

The five shipped artifacts now gate linkSQLite/linkPostgreSQL on the backend option. OpenSSL stays unconditional — DNSSEC RSA cImports it in the core path.

Two traps the obvious edit hits (both hit, both documented in the commit): lib's root module IS the shared dns module, so linking through lib put -lpq on every importer; and the postgres backend TEST imports src/backends/postgres.zig explicitly even under backend=memory, needing the libpq include path at module compile time. Resolution: SEARCH paths on the module unconditionally, LINK inputs backend-gated per artifact.

Verified locally: zig build test green (3245 tests incl. the postgres backend test), the four packaged binaries link only ssl/crypto+libc, -Dbackend=sqlite still links libsqlite3.

Lands via the release train: declare a release of zdns once the matching nfpm depends trim (sean/pipelines) is live. That release should mint v0.1.12 by claim takeover from the abandoned attempt.

The shipped binaries carried `DT_NEEDED` for libpq5 and libsqlite3-0 while compiling the memory backend — symbols nothing could call. The deb honestly declared the matching depends, and its install test died on `libpq5 [no choices]` in every tester image, which is half of why zdns could not release (the other half, the release-path compile dispatch, was fixed in pipelines v0.1.638). The five shipped artifacts now gate `linkSQLite`/`linkPostgreSQL` on the backend option. OpenSSL stays unconditional — DNSSEC RSA cImports it in the core path. Two traps the obvious edit hits (both hit, both documented in the commit): `lib`'s root module IS the shared dns module, so linking through lib put `-lpq` on every importer; and the postgres backend TEST imports `src/backends/postgres.zig` explicitly even under backend=memory, needing the libpq include path at module compile time. Resolution: SEARCH paths on the module unconditionally, LINK inputs backend-gated per artifact. Verified locally: `zig build test` green (3245 tests incl. the postgres backend test), the four packaged binaries link only ssl/crypto+libc, `-Dbackend=sqlite` still links libsqlite3. Lands via the release train: declare a release of zdns once the matching nfpm depends trim (sean/pipelines) is live. That release should mint v0.1.12 by claim takeover from the abandoned attempt.
fix(build): link sqlite and libpq only when the backend needs them
All checks were successful
pipeline/ci CI green @ fc71788358be
fc71788358
Every artifact linked ssl, crypto, sqlite3, AND pq unconditionally, so the
shipped binaries carried DT_NEEDED entries for backends that were not
compiled in. The pipeline builds with the default backend (memory), and the
deb declares the matching depends — so the package demanded libpq5 and
libsqlite3-0 for symbols nothing could ever call, and the deb install test
died on libpq5 ("[no choices]") in every tester image.

The five shipped artifacts now gate linkSQLite/linkPostgreSQL on the
backend option. OpenSSL stays unconditional: DNSSEC RSA (algorithms 8 and
10) cImports it in the core path regardless of backend.

One subtlety made the obvious edit wrong twice. lib's root module IS the
shared dns module, so linking through lib put -lpq on the module itself and
every importer inherited it; and the postgres backend TEST imports
src/backends/postgres.zig explicitly even under backend=memory, so its
cImport needs the libpq include path at module compile time. The fix
separates the two concerns: the SEARCH paths sit on the dns module
unconditionally (a search path adds no runtime dependency), and the -lpq /
-lsqlite3 link inputs are backend-gated per artifact. Test and bench
artifacts keep unconditional linkage — they exercise every backend and the
zig-builder image carries the libraries.

Verified: zig build test passes (3245 tests, postgres backend test
included); the four packaged binaries link only ssl/crypto + libc under the
default backend; -Dbackend=sqlite still links libsqlite3.

The nfpm depends trim to match ships separately in sean/pipelines.
pipeline-bot force-pushed fix/conditional-backend-linkage from fc71788358
All checks were successful
pipeline/ci CI green @ fc71788358be
to 8b266570fa
All checks were successful
pipeline/ci CI green @ 8b266570fa94
2026-08-13 15:49:29 +00:00
Compare
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sean/zdns!32
No description provided.