aboutsummaryrefslogtreecommitdiff
path: root/src/Haddock/Interface.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Haddock/Interface.hs')
-rw-r--r--src/Haddock/Interface.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Haddock/Interface.hs b/src/Haddock/Interface.hs
index 8f8399df..aa77e042 100644
--- a/src/Haddock/Interface.hs
+++ b/src/Haddock/Interface.hs
@@ -86,7 +86,20 @@ createInterfaces' modules flags instIfaceMap = do
targets <- mapM (\f -> guessTarget f Nothing) modules
setTargets targets
modgraph <- depanal [] False
- let orderedMods = flattenSCCs $ topSortModuleGraph False modgraph Nothing
+
+ -- If template haskell is used by the package, we can not use
+ -- HscNothing as target since we might need to run code generated from
+ -- one or more of the modules during typechecking.
+ modgraph' <- if needsTemplateHaskell modgraph
+ then do
+ dflags <- getSessionDynFlags
+ setSessionDynFlags dflags { hscTarget = HscC }
+ -- we need to set HscC on all the ModSummaries as well
+ let addHscC m = m { ms_hspp_opts = (ms_hspp_opts m) { hscTarget = HscC } }
+ return (map addHscC modgraph)
+ else return modgraph
+
+ let orderedMods = flattenSCCs $ topSortModuleGraph False modgraph' Nothing
(ifaces, _) <- foldM (\(ifaces, modMap) modsum -> do
x <- processModule modsum flags modMap instIfaceMap
#else