feat(windows): make libpq and abseil-cpp build for a mingw host - #4
Merged
Conversation
Both are declared by Logos modules in metadata nix.packages.runtime and neither builds for x86_64-w64-mingw32. Fixed here rather than in each consumer, since metadata has no per-platform gating (parseMetadata.nix produces one flat list). Common cause: nixpkgs builds mingw-w64 against mcfgthread, so pthread.h and libpthread.a are absent from the whole cross closure. This is the fifth unrelated-looking failure from that one hole -- libpq, Rust's windows-gnu std, lsquic's clock_gettime64, nim-boringssl, and now abseil -- and each time the fix is windows.pthreads in buildInputs. abseil-cpp: thread_identity.cc includes <pthread.h> unconditionally. libpq: four obstacles -- curlSupport=false (postgres 18 links libcurl for OAuth, and curl cross drags in ngtcp2 -> nghttp3, whose EXAMPLES include <arpa/inet.h>); drop make-shell-wrapper-hook (wants a HOST bash, which mingw does not build, and libpq never calls wrapProgram); windows.pthreads; separateDebugInfo=false (that hook is the ELF split). The libpq entry is the CLIENT library only. Full postgresql has no mingw build and is deliberately not exposed -- a module wanting postgres should declare libpq, which is all it ever links or dlopens. Verified: abseil-cpp builds producing libabsl_*.dll.a; libpq.dll builds, loads on real Windows 10.0.26200, and PQconnectdb/PQexec/PQfinish/ PQlibVersion resolve. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two nixpkgs packages that Logos modules declare in
metadata.jsonnix.packages.runtimebut that do not build for a mingw host. Both fixed hererather than in each consumer, alongside the existing
cli11/glib/sqlite/
libwebpentries.The common cause
nixpkgs builds mingw-w64 against mcfgthread, so
pthread.handlibpthread.ado not exist anywhere in the default cross closure. Anythingcarrying an unconditional POSIX-threads assumption fails, and it fails late —
during compilation of a transitive dependency, far from whatever declared it.
This is the same hole that has already produced four other unrelated-looking
failures during the Windows port: libpq's
pthread_barrier_wait.c, Rust'sx86_64-pc-windows-gnustd wanting-l:libpthread.a, lsquic'sclock_gettime64, and nim-boringssl. Addingwindows.pthreadsto the offendingpackage's
buildInputsis the whole fix in each case.abseil-cppOne line. Verified: builds clean for
x86_64-w64-mingw32with the fix, producinglibabsl_*.dll.a.libpqFour unrelated obstacles, none of them individually interesting:
curlSupport = false— postgres 18 links libcurl for its OAuth deviceflow, and curl cross to mingw drags in ngtcp2 → nghttp3, whose examples
#include <arpa/inet.h>and fail. Nothing in Logos uses OAuth auth.make-shell-wrapper-hook—makeWrapperresolves to ahost-platform bash, and mingw bash does not build. libpq never calls
wrapProgram; the hook is vestigial.windows.pthreads— the mcfgthread gap above.separateDebugInfo = false— that hook runsobjcopy --only-keep-debug,which is the ELF split.
Note this is the client library only. Full
postgresql(the server) has nomingw build and is deliberately not made available — a module that wants
postgres should declare
libpq, which is all it ever links ordlopens anyway(see logos-co/logos-delivery-module#85, which corrects exactly that
declaration).
Verified:
libpq.dllbuilds, loads on real Windows 10.0.26200, andPQconnectdb/PQexec/PQfinish/PQlibVersionresolve. Its import table isfully Nix-tracked — Windows system DLLs plus the two OpenSSL DLLs, which
win-dll-link.shalready stages.Why these two, now
logos-delivery-moduleneedslibpq;logos-chat-uideclaresabseil-cpp.Neither could be expressed per-platform in
metadata.json—parseMetadata.nixproduces one flat list with no host gating — so the fix hasto live in the package set.
A note for reviewers
Both entries are narrow
overrideAttrson top of upstream. If this pattern keepsrecurring (this is the fifth instance), the alternative worth considering is
making the whole cross set use a pthreads-providing thread model rather than
mcfgthread, which would fix the class instead of the instances. That is a much
larger change — it rebuilds the entire Windows closure — so I have not attempted
it here, but it may be the right long-term answer.
🤖 Generated with Claude Code