static-haskell-nix icon indicating copy to clipboard operation
static-haskell-nix copied to clipboard

Patch cabal to pass --static flags to pkg-config

Open nh2 opened this issue 4 years ago • 5 comments

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.

nh2 avatar Oct 21 '19 12:10 nh2

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.

nh2 avatar Nov 08 '19 00:11 nh2

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.

nh2 avatar Nov 09 '19 01:11 nh2

Blocking Hadrian issue that prevenets me from adding fields to Cabal:

https://gitlab.haskell.org/ghc/ghc/issues/17468

nh2 avatar Nov 12 '19 01:11 nh2

https://gitlab.haskell.org/ghc/ghc/issues/17468 has been fixed!

alexbiehl avatar Aug 05 '20 08:08 alexbiehl

@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?

alexbiehl avatar Aug 05 '20 08:08 alexbiehl