2
votes

I'm trying to get Stack working on an Arch system. I've done the usual:

pacman -S ghc stack cabal-install

And then placed the following in ~/.stack/config.yaml, so that the system GHC is used and dynamic libraries are used (the packages above do not include static libraries):

system-ghc: true
ghc-options:
  "$everything": -dynamic
configure-options:
  "$everything":
  - -dynamic

But when I try to install something, (i.e. stack install wai) I see that it attempts to build a custom Setup script:

/usr/bin/ghc-8.6.5 -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-2.4.0.1 /home/alba/.stack/setup-exe-src/setup-mPHDZzAJ.hs /home/alba/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /home/alba/.stack/setup-exe-cache/x86_64-linux/tmp-Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5

And my options are not honored, so the build tries to use static libraries (and fails). Is there any way to get Stack/Cabal to use certain options when building Setup.hs?

1

1 Answers

-1
votes

EDIT: I found the relevant issues; it doesn't seem to be possible:

stack: Can't use system GHC without static libraries at all (#3409)
cabal: executable-dynamic: True should apply to build-type: Custom setup #1720

Related: It seems cabal will always attempt to build static + dynamic in some cases, even if you tell it otherwise.


For now, a partial solution I ended up using is to force the option with a wrapper.

At ~/.local/bin/ghc-8.6.5 put:

#!/bin/sh
exec /usr/bin/ghc-8.6.5 -dynamic "$@"

Then:

cd ~/.local/bin
chmod +x ghc-8.6.5
ln -s ghc{-8.6.5,}

ln -s {/usr/bin,.}/ghc-pkg-8.6.5
ln -s {/usr/bin,.}/runghc-8.6.5
ln -s {/usr/bin,.}/haddock-ghc-8.6.5

Make sure it's in your PATH and you're good to go.