Skip to content

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

Open

Description

@ramirez7

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

Activity

  1. phadej commented on Oct 3, 2020

    @phadej
    Collaborator

    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.

  2. fendor commented on Oct 21, 2020

    @fendor
    Collaborator

    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.

  3. fendor commented on Oct 21, 2020

    @fendor
    Collaborator

    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

  4. added this to the Considered for 3.10 milestone on Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions