haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.62k stars 691 forks source link

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

Open ramirez7 opened 4 years ago

ramirez7 commented 4 years ago

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

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
phadej commented 4 years ago

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.

fendor commented 4 years ago

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 commented 4 years ago

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