Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haddock 2.23.0 regression: --hyperlinked-source breaks vault-0.3.1.3 #1091

Closed
RyanGlScott opened this issue Sep 27, 2019 · 3 comments · Fixed by #1092
Closed

Haddock 2.23.0 regression: --hyperlinked-source breaks vault-0.3.1.3 #1091

RyanGlScott opened this issue Sep 27, 2019 · 3 comments · Fixed by #1092
Labels

Comments

@RyanGlScott
Copy link
Member

The vault-0.3.1.3 library no longer works with stack haddock on a GHC 8.8.1-based resolver (such as this one). After some digging, I discovered that the culprit is stack haddock's use of the --hyperlinked-source flag. To reproduce the issue, pick one of the following options (depending on your favorite build tool):

  • stack

    $ stack unpack vault-0.3.1.3 && cd vault-0.3.1.3
    Unpacked vault (from Hackage) to /home/rgscott/Documents/Hacking/Haskell/vault-0.3.1.3/
    
    $ stack --resolver nightly-2019-09-27 init
    Looking for .cabal or package.yaml files to use to init the project.
    Using cabal packages:
    - ./
    
    Selected resolver: nightly-2019-09-27
    Initialising configuration using resolver: nightly-2019-09-27
    Total number of user packages considered: 1
    Writing configuration to file: stack.yaml
    All done.
    
    $ stack haddock
    Stack has not been tested with GHC versions above 8.6, and using 8.8.1, this may fail
    Stack has not been tested with Cabal versions above 2.4, but version 3.0.0.0 was found, this may fail
    vault> configure (lib)
    Configuring vault-0.3.1.3...
    vault> build (lib)
    Preprocessing library for vault-0.3.1.3..
    Building library for vault-0.3.1.3..
    [1 of 5] Compiling Data.Unique.Really
    
    /home/rgscott/Documents/Hacking/Haskell/vault-0.3.1.3/src/Data/Unique/Really.hs:6:1: warning: [-Wunused-imports]
        The import of ‘Control.Applicative’ is redundant
          except perhaps to import instances from ‘Control.Applicative’
        To import instances alone, use: import Control.Applicative()
      |
    6 | import Control.Applicative ((<$>))
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [2 of 5] Compiling Data.Vault.ST.Lazy
    
    /home/rgscott/Documents/Hacking/Haskell/vault-0.3.1.3/src/Data/Vault/ST/ST.h:15:1: warning: [-Wunused-imports]
        The import of ‘Data.Monoid’ is redundant
          except perhaps to import instances from ‘Data.Monoid’
        To import instances alone, use: import Data.Monoid()
       |
    15 | import Data.Monoid (Monoid(..))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    /home/rgscott/Documents/Hacking/Haskell/vault-0.3.1.3/src/Data/Vault/ST/ST.h:16:1: warning: [-Wunused-imports]
        The import of ‘Data.Semigroup’ is redundant
          except perhaps to import instances from ‘Data.Semigroup’
        To import instances alone, use: import Data.Semigroup()
       |
    16 | import Data.Semigroup (Semigroup((<>)))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    /home/rgscott/Documents/Hacking/Haskell/vault-0.3.1.3/src/Data/Vault/ST/ST.h:18:1: warning: [-Wunused-imports]
        The import of ‘Control.Applicative’ is redundant
          except perhaps to import instances from ‘Control.Applicative’
        To import instances alone, use: import Control.Applicative()
       |
    18 | import Control.Applicative ((<$>))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [3 of 5] Compiling Data.Vault.Lazy
    [4 of 5] Compiling Data.Vault.ST.Strict
    
    /home/rgscott/Documents/Hacking/Haskell/vault-0.3.1.3/src/Data/Vault/ST/ST.h:15:1: warning: [-Wunused-imports]
        The import of ‘Data.Monoid’ is redundant
          except perhaps to import instances from ‘Data.Monoid’
        To import instances alone, use: import Data.Monoid()
       |
    15 | import Data.Monoid (Monoid(..))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    /home/rgscott/Documents/Hacking/Haskell/vault-0.3.1.3/src/Data/Vault/ST/ST.h:16:1: warning: [-Wunused-imports]
        The import of ‘Data.Semigroup’ is redundant
          except perhaps to import instances from ‘Data.Semigroup’
        To import instances alone, use: import Data.Semigroup()
       |
    16 | import Data.Semigroup (Semigroup((<>)))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    /home/rgscott/Documents/Hacking/Haskell/vault-0.3.1.3/src/Data/Vault/ST/ST.h:18:1: warning: [-Wunused-imports]
        The import of ‘Control.Applicative’ is redundant
          except perhaps to import instances from ‘Control.Applicative’
        To import instances alone, use: import Control.Applicative()
       |
    18 | import Control.Applicative ((<$>))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [5 of 5] Compiling Data.Vault.Strict
    
    vault> haddock
    Preprocessing library for vault-0.3.1.3..
    Running Haddock on library for vault-0.3.1.3..
    
    src/Data/Unique/Really.hs:6:1: warning: [-Wunused-imports]
        The import of ‘Control.Applicative’ is redundant
          except perhaps to import instances from ‘Control.Applicative’
        To import instances alone, use: import Control.Applicative()
      |
    6 | import Control.Applicative ((<$>))
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    src/Data/Vault/ST/ST.h:15:1: warning: [-Wunused-imports]
        The import of ‘Data.Monoid’ is redundant
          except perhaps to import instances from ‘Data.Monoid’
        To import instances alone, use: import Data.Monoid()
       |
    15 | import Data.Monoid (Monoid(..))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    src/Data/Vault/ST/ST.h:16:1: warning: [-Wunused-imports]
        The import of ‘Data.Semigroup’ is redundant
          except perhaps to import instances from ‘Data.Semigroup’
        To import instances alone, use: import Data.Semigroup()
       |
    16 | import Data.Semigroup (Semigroup((<>)))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    src/Data/Vault/ST/ST.h:18:1: warning: [-Wunused-imports]
        The import of ‘Control.Applicative’ is redundant
          except perhaps to import instances from ‘Control.Applicative’
        To import instances alone, use: import Control.Applicative()
       |
    18 | import Control.Applicative ((<$>))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    src/Data/Vault/ST/ST.h:15:1: warning: [-Wunused-imports]
        The import of ‘Data.Monoid’ is redundant
          except perhaps to import instances from ‘Data.Monoid’
        To import instances alone, use: import Data.Monoid()
       |
    15 | import Data.Monoid (Monoid(..))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    src/Data/Vault/ST/ST.h:16:1: warning: [-Wunused-imports]
        The import of ‘Data.Semigroup’ is redundant
          except perhaps to import instances from ‘Data.Semigroup’
        To import instances alone, use: import Data.Semigroup()
       |
    16 | import Data.Semigroup (Semigroup((<>)))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    src/Data/Vault/ST/ST.h:18:1: warning: [-Wunused-imports]
        The import of ‘Control.Applicative’ is redundant
          except perhaps to import instances from ‘Control.Applicative’
        To import instances alone, use: import Control.Applicative()
       |
    18 | import Control.Applicative ((<$>))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Haddock coverage:
     100% (  4 /  4) in 'Data.Unique.Really'
      80% ( 12 / 15) in 'Data.Vault.ST.Lazy'
      Missing documentation for:
        Vault (src/Data/Vault/ST/backends/GHC.h:18)
        Key (src/Data/Vault/ST/backends/GHC.h:19)
        Locker (src/Data/Vault/ST/backends/GHC.h:40)
     100% ( 15 / 15) in 'Data.Vault.Lazy'
      80% ( 12 / 15) in 'Data.Vault.ST.Strict'
      Missing documentation for:
        Vault (src/Data/Vault/ST/backends/GHC.h:18)
        Key (src/Data/Vault/ST/backends/GHC.h:19)
        Locker (src/Data/Vault/ST/backends/GHC.h:40)
     100% ( 15 / 15) in 'Data.Vault.Strict'
    haddock: internal error: couldn't find ast for src/Data/Vault/ST/Lazy.hs ["src/Data/Vault/ST/ST.h","src/Data/Vault/ST/backends/GHC.h"]
    CallStack (from HasCallStack):
      error, called at utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs:78:28 in main:Haddock.Backends.Hyperlinker
    
    --  While building package vault-0.3.1.3 using:
          /home/rgscott/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_3.0.0.0_ghc-8.8.1 --builddir=.stack-work/dist/x86_64-linux/Cabal-3.0.0.0 haddock --html --hoogle --html-location=../$pkg-$version/ --haddock-option=--hyperlinked-source --haddock-option=--quickjump
        Process exited with code: ExitFailure 1
    
  • cabal

    $ cabal get vault-0.3.1.3 && cd vault-0.3.1.3                                                      
    Unpacking to vault-0.3.1.3/
    
    $ /opt/ghc/8.8.1/bin/haddock --version
    Haddock version 2.23.0, (c) Simon Marlow 2006
    Ported to use the GHC API by David Waern 2006-2008
    
    $ cabal haddock -w /opt/ghc/8.8.1/bin/ghc --haddock-option=--hyperlinked-source
    Resolving dependencies...
    Build profile: -w ghc-8.8.1 -O1
    In order, the following will be built (use -v for more details):
     - vault-0.3.1.3 (first run)
    Configuring vault-0.3.1.3...
    Preprocessing library for vault-0.3.1.3..
    Running Haddock on library for vault-0.3.1.3..
    Warning: The documentation for the following packages are not installed. No
    links will be generated to these packages: hashable-1.3.0.0,
    semigroups-0.19.1, unordered-containers-0.2.10.0
    Haddock coverage:
    
    src/Data/Unique/Really.hs:6:1: warning: [-Wunused-imports]
        The import of ‘Control.Applicative’ is redundant
          except perhaps to import instances from ‘Control.Applicative’
        To import instances alone, use: import Control.Applicative()
      |
    6 | import Control.Applicative ((<$>))
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     100% (  4 /  4) in 'Data.Unique.Really'
    
    src/Data/Vault/ST/ST.h:15:1: warning: [-Wunused-imports]
        The import of ‘Data.Monoid’ is redundant
          except perhaps to import instances from ‘Data.Monoid’
        To import instances alone, use: import Data.Monoid()
       |
    15 | import Data.Monoid (Monoid(..))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    src/Data/Vault/ST/ST.h:16:1: warning: [-Wunused-imports]
        The import of ‘Data.Semigroup’ is redundant
          except perhaps to import instances from ‘Data.Semigroup’
        To import instances alone, use: import Data.Semigroup()
       |
    16 | import Data.Semigroup (Semigroup((<>)))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    src/Data/Vault/ST/ST.h:18:1: warning: [-Wunused-imports]
        The import of ‘Control.Applicative’ is redundant
          except perhaps to import instances from ‘Control.Applicative’
        To import instances alone, use: import Control.Applicative()
       |
    18 | import Control.Applicative ((<$>))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      80% ( 12 / 15) in 'Data.Vault.ST.Lazy'
      Missing documentation for:
        Vault (src/Data/Vault/ST/backends/GHC.h:18)
        Key (src/Data/Vault/ST/backends/GHC.h:19)
        Locker (src/Data/Vault/ST/backends/GHC.h:40)
     100% ( 15 / 15) in 'Data.Vault.Lazy'
    
    src/Data/Vault/ST/ST.h:15:1: warning: [-Wunused-imports]
        The import of ‘Data.Monoid’ is redundant
          except perhaps to import instances from ‘Data.Monoid’
        To import instances alone, use: import Data.Monoid()
       |
    15 | import Data.Monoid (Monoid(..))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    src/Data/Vault/ST/ST.h:16:1: warning: [-Wunused-imports]
        The import of ‘Data.Semigroup’ is redundant
          except perhaps to import instances from ‘Data.Semigroup’
        To import instances alone, use: import Data.Semigroup()
       |
    16 | import Data.Semigroup (Semigroup((<>)))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    src/Data/Vault/ST/ST.h:18:1: warning: [-Wunused-imports]
        The import of ‘Control.Applicative’ is redundant
          except perhaps to import instances from ‘Control.Applicative’
        To import instances alone, use: import Control.Applicative()
       |
    18 | import Control.Applicative ((<$>))
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      80% ( 12 / 15) in 'Data.Vault.ST.Strict'
      Missing documentation for:
        Vault (src/Data/Vault/ST/backends/GHC.h:18)
        Key (src/Data/Vault/ST/backends/GHC.h:19)
        Locker (src/Data/Vault/ST/backends/GHC.h:40)
     100% ( 15 / 15) in 'Data.Vault.Strict'
    Warning: Data.Unique.Really: could not find link destinations for:
        Hashable hashWithSalt hash
    haddock: internal error: couldn't find ast for src/Data/Vault/ST/Lazy.hs ["src/Data/Vault/ST/ST.h","src/Data/Vault/ST/backends/GHC.h"]
    CallStack (from HasCallStack):
      error, called at utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs:78:28 in main:Haddock.Backends.Hyperlinker
    cabal: Failed to build documentation for vault-0.3.1.3.
    

This is a regression from Haddock 2.22.0, which does not error:

$ /opt/ghc/8.6.5/bin/haddock --version
Haddock version 2.22.0, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008

$ cabal haddock -w /opt/ghc/8.6.5/bin/ghc --haddock-option=--hyperlinked-source
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
 - vault-0.3.1.3 (first run)
Configuring vault-0.3.1.3...
Preprocessing library for vault-0.3.1.3..
Running Haddock on library for vault-0.3.1.3..
Warning: The documentation for the following packages are not installed. No
links will be generated to these packages: hashable-1.3.0.0,
semigroups-0.19.1, unordered-containers-0.2.10.0
Haddock coverage:
 100% (  4 /  4) in 'Data.Unique.Really'
  80% ( 12 / 15) in 'Data.Vault.ST.Lazy'
  Missing documentation for:
    Vault (src/Data/Vault/ST/backends/GHC.h:18)
    Key (src/Data/Vault/ST/backends/GHC.h:19)
    Locker (src/Data/Vault/ST/backends/GHC.h:40)
 100% ( 15 / 15) in 'Data.Vault.Lazy'
  80% ( 12 / 15) in 'Data.Vault.ST.Strict'
  Missing documentation for:
    Vault (src/Data/Vault/ST/backends/GHC.h:18)
    Key (src/Data/Vault/ST/backends/GHC.h:19)
    Locker (src/Data/Vault/ST/backends/GHC.h:40)
 100% ( 15 / 15) in 'Data.Vault.Strict'
Warning: Data.Unique.Really: could not find link destinations for:
    Hashable hashWithSalt hash
Documentation created:
/home/rgscott/Documents/Hacking/Haskell/vault-0.3.1.3/dist-newstyle/build/x86_64-linux/ghc-8.6.5/vault-0.3.1.3/doc/html/vault/index.html

I'll try to come up with a more minimal test case shortly.

@RyanGlScott
Copy link
Member Author

Here is an example with no external dependencies. You'll need these three files:

-- Bug.hs
{-# LANGUAGE CPP #-}
module Bug where

#include "Foo.h"
/* Foo.h */

foo :: Int
foo = 42

#include "Bar.h"
/* Bar.h */

bar :: Int
bar = 27

This demonstrates that this setup works with Haddock 2.22.0:

$ /opt/ghc/8.6.5/bin/haddock --version && /opt/ghc/8.6.5/bin/haddock Bug.hs --hyperlinked-source
Haddock version 2.22.0, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
Haddock coverage:
Warning: Package name is not available.
   0% (  0 /  3) in 'Bug'
  Missing documentation for:
    Module header
    bar (Bar.h:3)
    foo (Foo.h:3)
Warning: Bug: could not find link destinations for:
    Int

But not with Haddock 2.23.0:

$ /opt/ghc/8.8.1/bin/haddock --version && /opt/ghc/8.8.1/bin/haddock Bug.hs --hyperlinked-source
Haddock version 2.23.0, (c) Simon Marlow 2006
Ported to use the GHC API by David Waern 2006-2008
Haddock coverage:
Warning: Package name is not available.
   0% (  0 /  3) in 'Bug'
  Missing documentation for:
    Module header
    bar (Bar.h:3)
    foo (Foo.h:3)
Warning: Bug: could not find link destinations for:
    Int
haddock: internal error: couldn't find ast for Bug.hs ["Bar.h","Foo.h"]
CallStack (from HasCallStack):
  error, called at utils/haddock/haddock-api/src/Haddock/Backends/Hyperlinker.hs:78:28 in main:Haddock.Backends.Hyperlinker

@wz1000
Copy link
Collaborator

wz1000 commented Sep 28, 2019

CPP strikes once again. The issue is that there are no SrcSpans from Bug.hs in the file, as all the SrcSpans reference the included header files.

I have made a PR that eliminates the call to error and logs the message instead. I can confirm that this fixes the crash on the minimal example you provided.

@sheaf
Copy link
Contributor

sheaf commented Oct 4, 2019

I ran into the same issue with vector-0.12.0.3, but @wz1000's patch fixed it for me.

haddock: internal error: couldn't find ast for Data\Vector\Fusion\Stream\Monadic.hs ["Data\\\\Vector\\\\Fusion\\\\Stream\\\\Monadic.hs","include/vector.h"]
CallStack (from HasCallStack):
  error, called at utils\haddock\haddock-api\src\Haddock\Backends\Hyperlinker.hs:78:28 in main:Haddock.Backends.Hyperlinker

harpocrates added a commit to wz1000/haddock that referenced this issue Oct 7, 2019
Previously, this input would crash Haddock.
harpocrates added a commit to wz1000/haddock that referenced this issue Oct 7, 2019
Previously, this input would crash Haddock.
harpocrates added a commit that referenced this issue Oct 7, 2019
Previously, this input would crash Haddock.
alexbiehl-gc pushed a commit to alexbiehl/haddock that referenced this issue Dec 8, 2020
Previously, this input would crash Haddock.
hubot pushed a commit to ghc/ghc that referenced this issue May 17, 2024
Previously, this input would crash Haddock.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants