diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-11-03 12:04:53 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-11-21 01:14:09 -0500 |
commit | ecfd0278cb811c93853c176fe5df60222d1a8fb5 (patch) | |
tree | 7fc212d973a0d9e5e67e13011bf30907b1458228 /compiler/GHC.hs | |
parent | 53ad67eacacde8fde452f1a323d5886183375182 (diff) | |
download | haskell-ecfd0278cb811c93853c176fe5df60222d1a8fb5.tar.gz |
Move Plugins into HscEnv (#17957)
Loaded plugins have nothing to do in DynFlags so this patch moves them
into HscEnv (session state).
"DynFlags plugins" become "Driver plugins" to still be able to register
static plugins.
Bump haddock submodule
Diffstat (limited to 'compiler/GHC.hs')
-rw-r--r-- | compiler/GHC.hs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/compiler/GHC.hs b/compiler/GHC.hs index 13d8ba5ec7..cc8f93bba0 100644 --- a/compiler/GHC.hs +++ b/compiler/GHC.hs @@ -313,6 +313,7 @@ import GHC.Driver.Monad import GHC.Driver.Ppr import GHC.ByteCode.Types +import GHC.Runtime.Loader import GHC.Runtime.Eval import GHC.Runtime.Eval.Types import GHC.Runtime.Interpreter @@ -729,6 +730,8 @@ getProgramDynFlags :: GhcMonad m => m DynFlags getProgramDynFlags = getSessionDynFlags -- | Set the 'DynFlags' used to evaluate interactive expressions. +-- Also initialise (load) plugins. +-- -- Note: this cannot be used for changes to packages. Use -- 'setSessionDynFlags', or 'setProgramDynFlags' and then copy the -- 'unitState' into the interactive @DynFlags@. @@ -736,7 +739,22 @@ setInteractiveDynFlags :: GhcMonad m => DynFlags -> m () setInteractiveDynFlags dflags = do dflags' <- checkNewDynFlags dflags dflags'' <- checkNewInteractiveDynFlags dflags' - modifySession $ \h -> h{ hsc_IC = (hsc_IC h) { ic_dflags = dflags'' }} + modifySessionM $ \hsc_env0 -> do + let ic0 = hsc_IC hsc_env0 + + -- Initialise (load) plugins in the interactive environment with the new + -- DynFlags + plugin_env <- liftIO $ initializePlugins $ mkInteractiveHscEnv $ + hsc_env0 { hsc_IC = ic0 { ic_dflags = dflags'' }} + + -- Update both plugins cache and DynFlags in the interactive context. + return $ hsc_env0 + { hsc_IC = ic0 + { ic_plugins = hsc_plugins plugin_env + , ic_dflags = hsc_dflags plugin_env + } + } + -- | Get the 'DynFlags' used to evaluate interactive expressions. getInteractiveDynFlags :: GhcMonad m => m DynFlags |