-
Notifications
You must be signed in to change notification settings - Fork 697
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
Cabal 3.8 expects pkg-config --libs --static
to always work.
#8455
Comments
@hamishmack: thank you for the report. Did it work fine with cabal 3.6.2 (I assume it's failing with 3.8.1?)? |
Yes, 3.6.2 worked fine (I think because it does not include bf32602) |
A bug was fixed in cabal 3.8 (haskell/cabal#6771) that haskell.nix relied on for `pkg-config` in support. To work around this we added a dummy `pkg-config` that `cabal configure` now uses when haskell.nix runs it `cabal configure` internally. That returns version information for all the `pkg-config` packages in `lib/pkgconfig-nixpkgs-map.nix`. This mapping has also been expanded based on the results of searching nixpkgs for `*.pc` files. This update also includes workarounds for: haskell/cabal#8352 haskell/cabal#8370 haskell/cabal#8455
associated ticket for the original change: #7536 cc @nh2 @alexbiehl |
The issue description doesn't say what the error message is. Is it like this?
An alternative to
would be to do what I did before this commit, conditionally passing the flag on bf32602#diff-fff9e57c2727835086925d886619deb3fafd33a06e1af760d60d485ae07cec68L1647 Edit: This alternative cannot work, see #8455 (comment) |
I can reproduce this as well and it is probably going to break a lot of packages in nixpkgs with no nice way of fixing them. When we have a Haskell package When we actually link the (system) libs statically, we propagate Accomodating Cabal here is hard, since it pertains how packaging of non-Haskell packages is done, so I'd prefer it if we could get rid of this requirement. |
@hamishmack: could you respond to #8455 (comment)? Thank you. @sternenseemann: I lack context, so I'd need more explanation of your proposal. Could you elaborate on "if we could get rid of this requirement"? What requirement? In which code the change would be done? |
The requirement in Cabal, i.e. that it runs The problem for nixpkgs is that from the cabal file we only know the libraries the package depends on directly and we want to avoid blindly adding all packages that package depends on to As said, the propagation of the transitive dependency closure is only necessary when we are actually producing fully statically linked executables (when we do, we propagate), but normally our executables are linked statically only against Haskell libs and dynamically against system libraries (including pkgconfig-depends) – which is the default I think. |
Also affects Cabal-3.9.0.0 as shipped by GHC 9.6.1-alpha2. |
I think we should follow the suggestion from @nh2 and only conditionally pass the static flag when the build is requested to be static. After inspecting the code for a bit, I think there is no downside here. |
Let's do that. |
@nh2: could you perhaps revert that one bit? That would be very helpful and we'd have it in time for cabal 3.10. |
@nh2: ping? |
Hey, I'm currently on business travels for the next 2.5 weeks, so I won't have time to look into that / test it thoroughly until after that. |
@nh2: thank you for letting us know. Lots of success in your travels! I'm afraid we can't wait with cabal 3.10.1.0 any longer, but we'd gladly incorporate a fix for the regression into 3.10.2.0, if that aligns with your plans. |
@nh2; gentle ping? |
@nh2; gentle ping again? |
@nh2; gentle ping again? |
I have looked into this now. Unfortunately my suggestion to re-introduce The way @alexbiehl did it with ldflags <- pkgconfig ("--libs" : pkgs)
ldflags_static <- pkgconfig ("--libs" : "--static" : pkgs) is generally right: The way this feature works is (added docs):
This means that at the time a Haskell library gets compiled,
That implies that Concrete exampleConsider the
|
Answering #8455 (comment):
@sternenseemann The above should answer that question. At the time you build a Haskell library, you do not know whether that library will eventually be used for building a dynamic executable, a static executable, or maybe even both static and dynamic executables. One could argue that for many Nix use cases, this can be known / propagated through since in Nix you specify your top-level goal (e.g. |
Solution approaches
For anybody who wants to give a shot at the |
I have edited the above message for lining out a simpler approach. |
@sternenseemann I see from the above linked ticket that you're open to patching cabal. What do you think about working on the "simpler" approach outlined by @nh2 ? |
@gbaz The cons nh2 outlines also affect us, i.e. interactive usage of I am not sure that the easy fix would be so quick to figure out and test that it'd be worth investigating just for the sake of Nix. |
@sternenseemann sorry, to be clear, I don't mean the "easy" approach (the first of the two). I mean the "better" but also "simpler" approach which is the edited version of the second approach: "When building a static Haskell executable with --enable-executable-static would just construct a pkg-config --libs --static invocation to which as arguments are given all the pkgconfig-depends of all recursive Haskell dependency libraries. " |
@gbaz That would work for us. |
Great, do you think you would be interested in picking it up? |
Cabal 3.8 has the same requirements as pkgsStatic even when linking dynamically, so this patch will be useful for compiling haskellPackages.libarchive. haskell/cabal#8455
How are things going? Is this still a valid approach? If so, would anybody like to get it set up? Thank you! |
I am currently swamped with tasks, so it is unlikely for me to be able to pick it up this year. |
@nh2: Hi, how are you? Maybe this year? :D |
See bf32602 and input-output-hk/haskell.nix#1642
I think it is unreasonable for cabal to expect
pkg-config --libs --static
to work when only dynamic libraries may be installed on a system.To Reproduce
In
setup configure
forhaskell-gi-base
you will see it has both:On nix you can run something like this to see the second one fail:
Expected behavior
Perhaps cabal could store the error and replay it when the linker arguments are actually needed.
The text was updated successfully, but these errors were encountered: