fix(build): link sqlite and libpq only when the backend needs them #32
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/conditional-backend-linkage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The shipped binaries carried
DT_NEEDEDfor 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 onlibpq5 [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/linkPostgreSQLon 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-lpqon every importer; and the postgres backend TEST importssrc/backends/postgres.zigexplicitly 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 testgreen (3245 tests incl. the postgres backend test), the four packaged binaries link only ssl/crypto+libc,-Dbackend=sqlitestill 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.
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.fc717883588b266570fa