static-haskell-nix
static-haskell-nix copied to clipboard
Patch cabal to pass --static flags to pkg-config
pkg-config takes a --static flag to output .a files for --libs. We currently add those manually in static-haskell-nix.
Instead, we should teach cabal to pass it, given that .cabal files can specify pkg-config dependencies.
Hopefully we can then get rid of pkg-config related overrides in static-haskell-nix and fundamentally fix issues like #57, so that Haskell libraries "remember" which static system libraries they need.
At NixCon I found that this requires adding a new field to ghc-pkg's .conf files, like extra-libraries-static, because libraries can't know at the time they invoke pkg-config whether they will eventually be linked statically or not, so we must carry along both sets of flags.
Before realising the above, I made a WIP for passing --static to pkg-config from cabal only:
https://github.com/nh2/cabal/tree/pkg-config-static-flag
Today I also made a WIP for the more significant change of adding the relevant fields to .conf files:
https://github.com/nh2/cabal/tree/extraLibrariesStatic-field
I still have to implement the GHC side.
Blocking Hadrian issue that prevenets me from adding fields to Cabal:
https://gitlab.haskell.org/ghc/ghc/issues/17468
https://gitlab.haskell.org/ghc/ghc/issues/17468 has been fixed!
@nh2 I am picking this up again. Can you elaborate what changes need to happen on the GHC side? Looking at
https://github.com/nh2/cabal/tree/extraLibrariesStatic-field I still have to implement the GHC side.
in https://github.com/nh2/static-haskell-nix/issues/62#issuecomment-552692276.
I was under the impression that Cabal would control the linker line and that GHC wouldn't need to do anything special with extra-libraries-static?