aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2009-01-10 19:35:42 +0000
committerDavid Waern <david.waern@gmail.com>2009-01-10 19:35:42 +0000
commit531fee6ea936ac6133de9b558a030f2a6c5cdf77 (patch)
treeececc052608bad252d81e0374c71f4ee17da3c39
parent3facdf199d720f64ea57dbfbb7cbbcb11afbff55 (diff)
Fix Trac #68: Turn on compilation via C for Template Haskell packages
We can't use HscNothing if we need to run code coming from modules inside the processed package during typechecking, which is the case for some packages using Template Haskell. This could be improved, to e.g. use HscInterpreted and HscNothing where possible, instead of using HscC for all modules in the package.
-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