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

Commit 39251d3

Browse files
authored
Load plugins when compiling each module (#983)
* WIP: Load (typechecker) plugins from language pragmas * Revert "Load plugins when starting a GHC session (#905)" This reverts commit 72d82e5. * Simplify plugin initialization code
1 parent a36ab92 commit 39251d3

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

haddock-api/src/Haddock.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ import Packages
7676
import Panic (handleGhcException)
7777
import Module
7878
import FastString
79-
import qualified DynamicLoading
8079

8180
--------------------------------------------------------------------------------
8281
-- * Exception handling
@@ -450,10 +449,7 @@ withGhc' libDir flags ghcActs = runGhc (Just libDir) $ do
450449
-- that may need to be re-linked: Haddock doesn't do any
451450
-- dynamic or static linking at all!
452451
_ <- setSessionDynFlags dynflags''
453-
hscenv <- GHC.getSession
454-
dynflags''' <- liftIO (DynamicLoading.initializePlugins hscenv dynflags'')
455-
_ <- setSessionDynFlags dynflags'''
456-
ghcActs dynflags'''
452+
ghcActs dynflags''
457453
where
458454

459455
-- ignore sublists of flags that start with "+RTS" and end in "-RTS"

haddock-api/src/Haddock/Interface.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import Name (nameIsFromExternalPackage, nameOccName)
6464
import OccName (isTcOcc)
6565
import RdrName (unQualOK, gre_name, globalRdrEnvElts)
6666
import ErrUtils (withTiming)
67+
import DynamicLoading (initializePlugins)
6768

6869
#if defined(mingw32_HOST_OS)
6970
import System.IO
@@ -177,7 +178,13 @@ createIfaces verbosity flags instIfaceMap mods = do
177178
processModule :: Verbosity -> ModSummary -> [Flag] -> IfaceMap -> InstIfaceMap -> Ghc (Maybe (Interface, ModuleSet))
178179
processModule verbosity modsum flags modMap instIfaceMap = do
179180
out verbosity verbose $ "Checking module " ++ moduleString (ms_mod modsum) ++ "..."
180-
tm <- {-# SCC "parse/typecheck/load" #-} loadModule =<< typecheckModule =<< parseModule modsum
181+
182+
-- Since GHC 8.6, plugins are initialized on a per module basis
183+
hsc_env' <- getSession
184+
dynflags' <- liftIO (initializePlugins hsc_env' (GHC.ms_hspp_opts modsum))
185+
let modsum' = modsum { ms_hspp_opts = dynflags' }
186+
187+
tm <- {-# SCC "parse/typecheck/load" #-} loadModule =<< typecheckModule =<< parseModule modsum'
181188

182189
if not $ isBootSummary modsum then do
183190
out verbosity verbose "Creating interface..."

0 commit comments

Comments
 (0)