Due to https://sourceware.org/bugzilla/show_bug.cgi?id=22948, if we specify extra-libraries: pq instead of extra-libraries: libpq within postgresql-libpq.cabal, then if you attempt to build postgresql-libpq against the official PostgreSQL distribution for Windows, then ld will link against libpq.dll directly (instead of the import library, libpq.lib). This can lead to segfaults, as libpq.dll will truncate R_X86_64_PC32 relocations.
As a (hopefully temporary) hack, we avoid this issue by forcing ld to link against the libpq.lib import library directly by specifying extra-libraries: libpq on Windows. I've confirmed that this works with both the official Windows PostgreSQL distribution as well as the MinGW-w64 version.
Due to https://sourceware.org/bugzilla/show_bug.cgi?id=22948, if we specify
extra-libraries: pq
instead ofextra-libraries: libpq
withinpostgresql-libpq.cabal
, then if you attempt to buildpostgresql-libpq
against the official PostgreSQL distribution for Windows, thenld
will link againstlibpq.dll
directly (instead of the import library,libpq.lib
). This can lead to segfaults, aslibpq.dll
will truncate R_X86_64_PC32 relocations.As a (hopefully temporary) hack, we avoid this issue by forcing
ld
to link against thelibpq.lib
import library directly by specifyingextra-libraries: libpq
on Windows. I've confirmed that this works with both the official Windows PostgreSQL distribution as well as the MinGW-w64 version.This should fix https://github.com/lpsmith/postgresql-libpq/issues/43.