packcheck icon indicating copy to clipboard operation
packcheck copied to clipboard

Provide a way to specify different ghc options for dependencies

Open jgm opened this issue 6 years ago • 5 comments

If I do

sh packcheck.sh cabal-new GHCVER=8.4.3 GHC_OPTIONS="-O0 -Werror -Wall"

then the build fails because of warnings compiling some of the dependencies. I'd like to be able to specify -Werror for the local build only, and not for the dependencies. This would require a two-phase build, first with cabal new-build --dependencies-only, and the ability to specify different options for the dependencies and the local build. (Or is there another way to work around this?)

(Great project, by the way! Aside from this issue, it is what I have been dreaming of.)

jgm avatar Jan 23 '19 18:01 jgm

@jgm thanks for raising the issue and for the feedback. I am aware of this issue, this shows only in cabal-new build, stack build does not have this issue as stack does not pass the ghc options to all dependencies by default. This is annoying, and I do not pass -Werror to cabal builds because of this.

This would require a two-phase build, first with cabal new-build --dependencies-only, and the ability to specify different options for the dependencies and the local build. (Or is there another way to work around this?)

I can try what you suggested. It would be nice if cabal itself supported a flag that passes ghc options only to the local packages and not dependencies. I am not really familiar with all of cabal's options. @hvr would you have an idea how to solve this in a nice way?

harendra-kumar avatar Jan 23 '19 19:01 harendra-kumar

@jgm using --only-dependencies in the first phase of a two-phase build does not solve this issue. cabal still rebuilds all dependencies if a different GHC flag is specified in the second build phase. I think this can only be solved once haskell/cabal#3883 gets resolved.

harendra-kumar avatar Jun 25 '19 09:06 harendra-kumar

@jgm #21 implements CABAL_PROJECT environment option to specify a custom cabal project file to solve this problem as suggested in the cabal issue mentioned above.

harendra-kumar avatar Jun 28 '19 14:06 harendra-kumar

Seems tedious to have to maintain two separate cabal.project files, one for local builds and one for CI.

jgm avatar Jul 06 '19 21:07 jgm

See #43 , that might solve this in a better way.

harendra-kumar avatar Jun 07 '21 18:06 harendra-kumar