cabal icon indicating copy to clipboard operation
cabal copied to clipboard

cabal v2-haddock isn't respecting --ghc-options

Open ramirez7 opened this issue 5 years ago • 3 comments

Describe the bug I am trying to run cabal v2-haddock --ghc-options='-Wwarn' but despite that, it is still erroring (due to my project-wide -Werror)

cabal v2-build --ghc-options='-Wwarn' successfully only warns instead of errors however.

To Reproduce

  • Add -Werror to your cabal file ghc options
  • Introduce a warning (e.g. unused variable)
  • cabal haddock --ghc-options='-Wwarn' will fail

Please use version-prefixed commands (e.g. v2-build or v1-build) to avoid ambiguity.

Expected behavior I would expect haddock generation to respect my ghc options. In this example, I would expect it to warn but not error.

System information

NixOS 20.03

cabal-install version 3.2.0.0
compiled using version 3.2.0.0 of the Cabal library 

The Glorious Glasgow Haskell Compilation System, version 8.6.5

ramirez7 avatar Oct 03 '20 21:10 ramirez7

I suspect that command line --ghc-options are not passed to haddock, verbose (cabal haddock -v2) output would help to figure out what is called and how.

phadej avatar Oct 03 '20 23:10 phadej

Just sparing someone running cabal with -v2:

>  cabal haddock  -v2 --ghc-options='-Wwarn' 
...
Build profile: -w ghc-8.8.4 -O1
In order, the following will be built:
 - cabal-haddock-0.1.0.0 (lib) (file src/MyLib.hs changed)
creating /home/munin/Documents/haskell/cabal-haddock/dist-newstyle/build
creating /home/munin/Documents/haskell/cabal-haddock/dist-newstyle/tmp
creating
/home/munin/Documents/haskell/cabal-haddock/dist-newstyle/build/x86_64-linux/ghc-8.8.4/cabal-haddock-0.1.0.0
creating
/home/munin/Documents/haskell/cabal-haddock/dist-newstyle/build/x86_64-linux/ghc-8.8.4/cabal-haddock-0.1.0.0/cache
whenReRegister: nothing to register
Using self-exec internal setup method with build-type Simple and args:
["act-as-setup","--build-type=Simple","--","haddock","--verbose=2","--builddir=/home/munin/Documents/haskell/cabal-haddock/dist-newstyle/build/x86_64-linux/ghc-8.8.4/cabal-haddock-0.1.0.0","lib:cabal-haddock"]
/home/munin/.cabal/store/ghc-8.8.4/cabal-install-3.5.0.0-31243c8f02aa1caf3ec5ba134fc9692633f0f52de1e4a8f039787e5fd37726bd/bin/cabal
act-as-setup --build-type=Simple -- haddock --verbose=2
--builddir=/home/munin/Documents/haskell/cabal-haddock/dist-newstyle/build/x86_64-linux/ghc-8.8.4/cabal-haddock-0.1.0.0
lib:cabal-haddock
/home/munin/.nix-profile/bin/haddock --ghc-version
/home/munin/.nix-profile/bin/ghc --print-libdir -hide-all-packages -Wwarn
/home/munin/.nix-profile/bin/ghc-pkg init /home/munin/Documents/haskell/cabal-haddock/dist-newstyle/build/x86_64-linux/ghc-8.8.4/cabal-haddock-0.1.0.0/package.conf.inplace
creating
/home/munin/Documents/haskell/cabal-haddock/dist-newstyle/build/x86_64-linux/ghc-8.8.4/cabal-haddock-0.1.0.0/build
creating
/home/munin/Documents/haskell/cabal-haddock/dist-newstyle/build/x86_64-linux/ghc-8.8.4/cabal-haddock-0.1.0.0/build/autogen
creating
/home/munin/Documents/haskell/cabal-haddock/dist-newstyle/build/x86_64-linux/ghc-8.8.4/cabal-haddock-0.1.0.0/build/autogen
Preprocessing library for cabal-haddock-0.1.0.0..
Running Haddock on library for cabal-haddock-0.1.0.0..
creating
/home/munin/Documents/haskell/cabal-haddock/dist-newstyle/build/x86_64-linux/ghc-8.8.4/cabal-haddock-0.1.0.0/doc/html/cabal-haddock
/home/munin/.nix-profile/bin/haddock '@/home/munin/Documents/haskell/cabal-haddock/dist-newstyle/build/x86_64-linux/ghc-8.8.4/cabal-haddock-0.1.0.0/doc/html/cabal-haddock/haddock-response2926-1.txt'
...
cabal: Failed to build documentation for cabal-haddock-0.1.0.0-inplace.

Furthermore:

> runghc Setup.hs configure
> runghc Setup.hs haddock --ghc-options=-Wwarn

does not work either. (Assuming I finally did a correct Cabal incantation)

So, no cabal does not pass the relevant info, but even if it did, Cabal would not use it.

fendor avatar Oct 21 '20 18:10 fendor

Also, see this note:

setupHsHaddockFlags :: ElaboratedConfiguredPackage
                    -> ElaboratedSharedConfig
                    -> Verbosity
                    -> FilePath
                    -> Cabal.HaddockFlags
setupHsHaddockFlags (ElaboratedConfiguredPackage{..}) _ verbosity builddir =
    Cabal.HaddockFlags {
      haddockProgramPaths  = mempty, --unused, set at configure time
      haddockProgramArgs   = mempty, --unused, set at configure time
...

at https://github.com/haskell/cabal/blob/master/cabal-install/src/Distribution/Client/ProjectPlanning.hs#L3571

fendor avatar Oct 21 '20 19:10 fendor