From 531fee6ea936ac6133de9b558a030f2a6c5cdf77 Mon Sep 17 00:00:00 2001 From: David Waern Date: Sat, 10 Jan 2009 19:35:42 +0000 Subject: 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. --- src/Haddock/Interface.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3