-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static linking breaks with Postgres 12 #27
Comments
I got some helpful pointers from Postgres IRC. Linking a mailing list posts with the info here: It seems, indeed that to link PostgreSQL 12.0 libpq, libpgcommon and libpgport need to be linked as well. They aren't needed for PostgreSQL 11.x and earlier, so how to fix this in build.rs needs some thought. |
Jotting down some notes after delving into https://github.com/sgrif/pq-sys/blob/master/build.rs#L79 after some years. pkg-config and the Windows equivalent are at the moment enabled only by a feature, so most people are unlikely to end up using them. If pkg-config info is correct, it should work, but at the moment, even that isn't correct. PostgreSQL's pkg-config is missing Anyway, the real question here seems to be, how to ensure correct linking in the default case, which is by calling At the moment only the |
Hello! Thank you for maintaining I'm the author of If there's anything I can do to help out with |
@golddranks I'm trying to do the same thing (in fact, I'm trying to build commit 8bc178b, which is branch golddranks/fix_libpq_12_linking -- the one from #28). With PostgreSQL 13 and gcc 7.3, I get an error about the multiply defined symbol
Sure enough, I have found that the |
I can easily reproduce my problem without any Rust. Here's a full example. The problem is that libpq.a has a Outside of Rust, you can work around this with the I'm still testing it out, but I think a better solution suggested by @luqmana is this change to PR #28:
It does produce warnings at build time, but it seems to work. |
Essentially fixed by #46 which allows to build and statically link a vendored libpq version |
I tried to investigate the problems I mentioned having in #25 (comment) . Turns out my linking problems were not about OpenSSL at all. It was the combination of Postgres 12
libpq
and static linking with Musl that broke the build.Here's a script demonstrating the problem, using a simple C example program. (It uses Docker image I build as a part of my project https://gitlab.com/rust_musl_docker/image ):
If I add the linker flags
-lpgport
and-lpgcommon
like this:... it manages to build the binary.
I'm sure it's the same problem I'm encountering with
pq-sys
because adding those linker flags to the flags Rust passes tocc
makes the binary to link.I'm currently trying to engage with Postgres community to check whether the dependency to those two libraries are intentional or is there something I'm missing, so we'll know exactly what to fix.
The text was updated successfully, but these errors were encountered: