Open cblp opened 6 years ago
Hmm, interesting. So the issue is that .cabal components cannot override --ghc-options / --pedantic? Seems expected to me.
I think the issue here is that pedantic implies -Wall. This is convenient, but messes with circumstances like this. I don't think we can put -Wall before the component's options, because that part is done by the Cabal library.
I suggest adding a pedantic
flag to your package, and using that instead of --pedantic
.
If you expect that component can't override command-line options, then you must expect that module can't override command-line, too.
pedantic implies -Wall
Yes, it's obvious, and the problem starts after that.
The issue is that I can't develop expectations about meaning of stack's command-line options.
If you expect that component can't override command-line options, then you must expect that module can't override command-line, too.
Uhh, that's a detail of ghc. I believe that OPTIONS_GHC always overrides command line options. Are you using -fno-warn-
? Perhaps you are expecting enabling warnings in OPTIONS_GHC will reset which warnings are used? This is not how it is done typically. Instead, you should enable the superset of all warnings you want, and then disable them selectively in modules.
The issue is that I can't develop expectations about meaning of stack's command-line options.
Not sure what this means? These options are just passed to Cabal. We can't really do anything different here. Cabal adds them to the end, after the component options. This is sensible behavior.
Hm, I will try to answer these questions one more time, in other words.
I run stack build --ghc-options=-Wall
and expect everything is compiled with options -Wall
. OK.
I run stack build --ghc-options=-Wall
with -Wno-orphans
added to a module and expect this specific module will be compiled with -Wall -Wno-orphans
. OK.
I run stack build --ghc-options=-Wall
with -Wno-orphans
added to a component and expect this specific component will be compiled with -Wall -Wno-orphans
. FAIL?
Quoting myself from above:
These options are just passed to Cabal. We can't really do anything different here. Cabal adds them to the end, after the component options.
AFAIK the only way we can solve that is by changing cabal's behavior. These are just being passed into cabal, and it is making the choice to append the cli options after the component options. Is this ideal and consistent? You're right, it's not. Please open an issue on https://github.com/haskell/cabal about it.
Re-opening so that when this is revisited down the road, maybe there will be a way to do this with future versions of cabal.
stack-1.2 seems to work properly (per-component options are put after stack-command-line options).
What is the best way to test this against different versions of the stack?
--ghc-options
overridesghc-options
in component configuration but doesn't overrideOPTIONS_GHC
in the module.When I want to test my package, I run
stack test --pedantic
. When I want to disable some warnings for a single module, I put OPTIONS_GHC in it. When I want to disable some warnings for a single component, I can't do this! Component configuration can't override command-line options!