Skip to content
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

haskellPackages.postgresql-libpq fails to link on Darwin #50902

Closed
endgame opened this issue Nov 22, 2018 · 12 comments
Closed

haskellPackages.postgresql-libpq fails to link on Darwin #50902

endgame opened this issue Nov 22, 2018 · 12 comments
Labels
6.topic: darwin Running or building packages on Darwin

Comments

@endgame
Copy link
Contributor

endgame commented Nov 22, 2018

Issue description

The macOS build of haskellPackages.postgresql-libpq fails to link in recent nixpkgs; it looks like something's wrong with (at least) the smoke tests:

Preprocessing test suite 'smoke' for postgresql-libpq-0.9.4.2..
Building test suite 'smoke' for postgresql-libpq-0.9.4.2..
[1 of 1] Compiling Main             ( test/Smoke.hs, dist/build/smoke/smoke-tmp/Main.o )
Linking dist/build/smoke/smoke ...
clang-5.0: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]
clang-5.0: warning: argument unused during compilation: '-nopie' [-Wunused-command-line-argument]
Undefined symbols for architecture x86_64:
  "_ASN1_STRING_length", referenced from:
      _verify_peer_name_matches_certificate_name in libpq.a(fe-secure-openssl.o)

Full build.log

Steps to reproduce

This nix expression fails to build on macOS:

let
  nixpkgs = import (builtins.fetchTarball {
    url = "https://github.com/NixOS/nixpkgs/archive/5632aad4739c2fc342ea280cee47b5213f799491.zip";
    sha256 = "0zfzfhmbshdkgi5pl5sxh1l8r8m13vwgwsyafbixvc6pcc4sdrh3";
  }) {};
in
  nixpkgs.haskellPackages.postgresql-libpq

This is a regression: i can successfully enter a nix-shell using this package if I use an 18.09 channel.

Technical details

nix-info -m:

 - system: `"x86_64-darwin"`
 - host os: `Darwin 17.7.0, macOS 10.13.6`
 - multi-user?: `no`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.1.3`
 - channels(che347): `"nixpkgs-19.03pre159614.f52b7f5c345, nixpkgs-18.09-darwin-18.09pre152973.012b9e6c219"`
 - nixpkgs: `/Users/che347/.nix-defexpr/channels/nixpkgs`

I am not sure how best to proceed. Please let me know if I can provide more useful information.

@alyssais
Copy link
Member

Broken since ab1a64f

@endgame
Copy link
Contributor Author

endgame commented Nov 25, 2018

That missing

   librarySystemDepends = [ postgresql ];

line looks ominous. I'll investigate and see how things go on my friend's mac.

@ranjanibrickx
Copy link

I have the same issue as well.

nix-info -m
 - system: `"x86_64-darwin"`
 - host os: `Darwin 17.7.0, macOS 10.13.6`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.1.3`
 - channels(ranjanin): `"darwin, nixpkgs-19.03pre159739.3ae0407d3c9"`
 - channels(root): `"nixpkgs-19.03pre158225.fccfc775d11"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

@endgame
Copy link
Contributor Author

endgame commented Nov 26, 2018

I am trying to fix this on this branch: https://github.com/endgame/nixpkgs/tree/haskell-postgres-libpq

In 81ff25d23fcbf783ff9337c573e76e64e959e874 I add a postgresql.lib dependency to haskellPackages.postgresql-libpq, but that causes the build to fail earlier in building postgresql. These appear to be the critical lines:

error: /nix/store/p1zg3dnaaglqm34pq12ynfa2pc3r2lq8-cctools-port-895/bin/ranlib: can't open file: libpgtypes.a (No such file or directory)
ar: internal ranlib command failed

build.log

@LnL7
Copy link
Member

LnL7 commented Nov 28, 2018

These are all the compiler flags https://gist.github.com/LnL7/3f7f7e00a2c6b2ec15d27e1be139402f, there are no references to openssl there tho.

@LnL7
Copy link
Member

LnL7 commented Nov 28, 2018

Ah I think I see what's going on here, adding postgresql.lib before postgresql fixes the issue. I think it's finding the static libraries first and tries to use those instead. I see some stuff in the postgresql expression that's supposed to remove the static libraries.

There's a good chance that making this also handle *.dylib files will fix the issue without the workaround in the haskell package.
https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/sql/postgresql/default.nix#L73-L75

@LnL7 LnL7 added the 6.topic: darwin Running or building packages on Darwin label Nov 28, 2018
@endgame
Copy link
Contributor Author

endgame commented Nov 28, 2018

Thanks @LnL7 , I'll make a PR to use ${stdenv.hostPlatform.extensions.sharedLibrary} instead of .so in that script.

@endgame
Copy link
Contributor Author

endgame commented Nov 29, 2018

Is it correct to close an issue after the PR to fix it hits staging, or when it hits master?

@LnL7
Copy link
Member

LnL7 commented Nov 29, 2018

Github will do that automatically and it would take some effort to track when staging is merged back so the issue would often stay open otherwise. However for issues with a high impact it's sometimes opportune to keep them open to make them more discoverable and avoid people creating duplicates.

@endgame
Copy link
Contributor Author

endgame commented Nov 29, 2018

Thanks. For some reason this hasn't self-closed, so I'll do that now.

@endgame
Copy link
Contributor Author

endgame commented Jan 9, 2019

This still isn't working correctly - nixpkgs on darwin is not removing libpq.a despite libpq.dylib showing up in .lib

I will investigate.

@endgame endgame reopened this Jan 9, 2019
@endgame
Copy link
Contributor Author

endgame commented Jan 9, 2019

Disregard, I think my channel wan't updating for some reason.

@endgame endgame closed this as completed Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: darwin Running or building packages on Darwin
Projects
None yet
Development

No branches or pull requests

4 participants