Reputation: 51
While setting up a deploy pipeline for optimised builds of a server application, I ran into some trouble getting the GHC options right with stack-1.6.5.
In particular, from the docs it doesn't get clear to me how the various ways to specify GHC options work together and when and how they are applied.
As far as I can tell, there are X ways of specifying GHC options:
ghc-options:
in ~/.stack/config.yaml
and/or /etc/stack/config.yaml
, per package or with "$locals"
, "$targets"
or "$everything"
stack.yaml
file, per package or with "$locals"
, "$targets"
or "$everything"
package.yaml
/.cabal
file, globally or per targetstack.yaml
/package.yaml
/.cabal
files--ghc-options
apply-ghc-options:
setting locals
/targets
/everything
in stack.yaml
and ~/.stack/config.yaml
and/or /etc/stack/config.yaml
I'd like to know which options are applied in the different build phases snapshots/locals/targets in which order and in which cases they are additive or override options given elsewhere.
Upvotes: 5
Views: 2563
Reputation: 3295
good question, this is not adequately documented. These tend to be additive. Most of the logic for this is here: https://github.com/commercialhaskell/stack/blob/657937b0ac5dbef29114b43e9c69e2b57198af85/src/Stack/Build/Source.hs#L131 . Here's the order, where later items in the list come later in the options provided to ghc:
$everything
in ghc-options in stack.yaml$locals
in ghc-options in stack.yaml$targets
in ghc-options in stack.yaml-fhpc
(--coverage) / fprof-auto -fprof-cafs
(--profile) / -g
(--no-strip).--ghc-options
on the CLIThere is currently an issue where $everything
/ $locals
/ $targets
ghc-options specified in .stack/config.yaml
are not additive. Instead they are currently shadowed by the project stack.yaml
. There is a PR fixing this, it will probably get merged at some point: https://github.com/commercialhaskell/stack/pull/3781
Upvotes: 4