Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Error when Template Haskell is used and GHC is dynamic #256

Closed
ghc-mirror opened this issue May 8, 2014 · 2 comments
Closed

Error when Template Haskell is used and GHC is dynamic #256

ghc-mirror opened this issue May 8, 2014 · 2 comments
Assignees

Comments

@ghc-mirror
Copy link

Original reporter: the.dead.shall.rise@

This was 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 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.

@ghc-mirror ghc-mirror self-assigned this May 8, 2014
@ghc-mirror
Copy link
Author

Original reporter: the.dead.shall.rise@

You can see how we handle this in Cabal here: https://github.com/haskell/cabal/blob/master/Cabal/Distribution/Simple/GHC.hs (search for ghcDynamic).

@ghc-mirror
Copy link
Author

Original reporter: fuuzetsu@

Fix in HEAD.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant