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

Load plugins when compiling each module #983

Merged
merged 3 commits into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions haddock-api/src/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import Packages
import Panic (handleGhcException)
import Module
import FastString
import qualified DynamicLoading

--------------------------------------------------------------------------------
-- * Exception handling
Expand Down Expand Up @@ -450,10 +449,7 @@ withGhc' libDir flags ghcActs = runGhc (Just libDir) $ do
-- that may need to be re-linked: Haddock doesn't do any
-- dynamic or static linking at all!
_ <- setSessionDynFlags dynflags''
hscenv <- GHC.getSession
dynflags''' <- liftIO (DynamicLoading.initializePlugins hscenv dynflags'')
_ <- setSessionDynFlags dynflags'''
ghcActs dynflags'''
ghcActs dynflags''
where

-- ignore sublists of flags that start with "+RTS" and end in "-RTS"
Expand Down
9 changes: 8 additions & 1 deletion haddock-api/src/Haddock/Interface.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import Name (nameIsFromExternalPackage, nameOccName)
import OccName (isTcOcc)
import RdrName (unQualOK, gre_name, globalRdrEnvElts)
import ErrUtils (withTiming)
import DynamicLoading (initializePlugins)

#if defined(mingw32_HOST_OS)
import System.IO
Expand Down Expand Up @@ -177,7 +178,13 @@ createIfaces verbosity flags instIfaceMap mods = do
processModule :: Verbosity -> ModSummary -> [Flag] -> IfaceMap -> InstIfaceMap -> Ghc (Maybe (Interface, ModuleSet))
processModule verbosity modsum flags modMap instIfaceMap = do
out verbosity verbose $ "Checking module " ++ moduleString (ms_mod modsum) ++ "..."
tm <- {-# SCC "parse/typecheck/load" #-} loadModule =<< typecheckModule =<< parseModule modsum

-- Since GHC 8.6, plugins are initialized on a per module basis
hsc_env' <- getSession
dynflags' <- liftIO (initializePlugins hsc_env' (GHC.ms_hspp_opts modsum))
let modsum' = modsum { ms_hspp_opts = dynflags' }

tm <- {-# SCC "parse/typecheck/load" #-} loadModule =<< typecheckModule =<< parseModule modsum'

if not $ isBootSummary modsum then do
out verbosity verbose "Creating interface..."
Expand Down