[Haddock] [haddock] #256: Error when Template Haskell is used and GHC is dynamic
haddock
haddock at projects.haskell.org
Tue Sep 3 15:24:45 BST 2013
#256: Error when Template Haskell is used and GHC is dynamic
-------------------+--------------------------------------------------------
Reporter: refold | Owner:
Type: defect | Status: new
Priority: major | Milestone:
Version: 2.13.1 | Keywords:
-------------------+--------------------------------------------------------
This was [https://github.com/haskell/cabal/issues/1266 initially reported
as a Cabal bug], but I'm now convinced that it's better to solve this
issue on the Haddock side.
When trying to build documentation for a library that uses Template
Haskell (for example, `traverse-with-class`) with GHC HEAD, I get the
following error:
{{{
$ cabal configure -w ~/bin/ghc-head/bin/ghc
Resolving dependencies...
Configuring traverse-with-class-0.1...
$ cabal haddock --with-haddock ~/bin/ghc-head/bin/haddock
Running Haddock for traverse-with-class-0.1...
Preprocessing library traverse-with-class-0.1...
Haddock coverage:
0% ( 0 / 2) in 'Data.Generics.Traversable.Core'
100% ( 3 / 3) in 'Data.Generics.Traversable.TH'
dist/build/tmp-5360/Data/Generics/Traversable/Instances.hs:1:1:
cannot find normal object file
‛/tmp/.haddock-5369/Data/Generics/Traversable/Core.dyn_o’
while linking an interpreted expression
}}}
However, everything works fine with GHC 7.6.
The error is due to the fact that GHCi in GHC HEAD
[http://ghc.haskell.org/trac/ghc/wiki/DynamicGhcPrograms uses the system
linker] and so it requires the TH modules to be `.dyn_o` instead of `.o`
(otherwise they can't be loaded because of the ABI mismatch). So the issue
can be worked around by passing `--optghc=-dynamic-too` to `cabal
haddock`:
{{{
$ cabal haddock --with-haddock ~/bin/ghc-head/bin/haddock --haddock-
options="--optghc=-dynamic-too"
Running Haddock for traverse-with-class-0.1...
Preprocessing library traverse-with-class-0.1...
Haddock coverage:
0% ( 0 / 2) in 'Data.Generics.Traversable.Core'
100% ( 3 / 3) in 'Data.Generics.Traversable.TH'
100% ( 1 / 1) in 'Data.Generics.Traversable.Instances'
93% ( 13 / 14) in 'Data.Generics.Traversable'
Documentation created: dist/doc/html/traverse-with-class/index.html
}}}
We can work around this in Cabal, but I think that the right place to fix
this issue is Haddock itself (since it also happens when Haddock is run in
standalone mode - i.e. not being driven by `cabal haddock`).
To do this, you should do the equivalent of parsing the output of `ghc
--info` and invoking GHC with the `-dynamic` option (or `-dynamic-too` if
it's supported) when the output contains a `("GHC Dynamic","YES")` tuple.
I'm not quite sure how to implement this using GHC API, but it should be
possible.
--
Ticket URL: <http://trac.haskell.org/haddock/ticket/256>
haddock <http://www.haskell.org/haddock>
Haddock, The Haskell Documentation Tool
More information about the Haddock
mailing list