summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorChristiaan Baaij <christiaan.baaij@gmail.com>2018-11-22 11:50:51 -0500
committerBen Gamari <ben@smart-cactus.org>2018-11-22 13:14:01 -0500
commit599eaada382d04722219bfc319bde94591be3fb1 (patch)
tree462b6ad7a5df2be04a77df8b5404822ec4cf4b86 /ghc
parentf088c2d42aaa38b32482ea8c4324786123835e62 (diff)
downloadhaskell-599eaada382d04722219bfc319bde94591be3fb1.tar.gz
Load plugins in interactive session
Reviewers: bgamari, tdammers Reviewed By: tdammers Subscribers: monoidal, rwbarton, carter GHC Trac Issues: #15633 Differential Revision: https://phabricator.haskell.org/D5348
Diffstat (limited to 'ghc')
-rw-r--r--ghc/GHCi/UI.hs8
-rw-r--r--ghc/Main.hs17
2 files changed, 19 insertions, 6 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index 3de49b4c25..ae8ba0266f 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -68,6 +68,8 @@ import qualified Lexer
import StringBuffer
import Outputable hiding ( printForUser, printForUserPartWay )
+import DynamicLoading ( initializePlugins )
+
-- Other random utilities
import BasicTypes hiding ( isTopLevel )
import Config
@@ -2721,10 +2723,14 @@ newDynFlags interactive_only minus_opts = do
when (interactive_only && packageFlagsChanged idflags1 idflags0) $ do
liftIO $ hPutStrLn stderr "cannot set package flags with :seti; use :set"
- GHC.setInteractiveDynFlags idflags1
+ -- Load any new plugins
+ hsc_env0 <- GHC.getSession
+ idflags2 <- liftIO (initializePlugins hsc_env0 idflags1)
+ GHC.setInteractiveDynFlags idflags2
installInteractivePrint (interactivePrint idflags1) False
dflags0 <- getDynFlags
+
when (not interactive_only) $ do
(dflags1, _, _) <- liftIO $ GHC.parseDynamicFlags dflags0 lopts
new_pkgs <- GHC.setProgramDynFlags dflags1
diff --git a/ghc/Main.hs b/ghc/Main.hs
index 15b7aee43e..456ff905eb 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -56,6 +56,7 @@ import Util
import Panic
import UniqSupply
import MonadUtils ( liftIO )
+import DynamicLoading ( initializePlugins )
-- Imports for --abi-hash
import LoadIface ( loadUserInterface )
@@ -259,8 +260,9 @@ main' postLoadMode dflags0 args flagWarnings = do
DoMake -> doMake srcs
DoMkDependHS -> doMkDependHS (map fst srcs)
StopBefore p -> liftIO (oneShot hsc_env p srcs)
- DoInteractive -> ghciUI srcs Nothing
- DoEval exprs -> ghciUI srcs $ Just $ reverse exprs
+ DoInteractive -> ghciUI hsc_env dflags6 srcs Nothing
+ DoEval exprs -> ghciUI hsc_env dflags6 srcs $ Just $
+ reverse exprs
DoAbiHash -> abiHash (map fst srcs)
ShowPackages -> liftIO $ showPackages dflags6
DoFrontend f -> doFrontend f srcs
@@ -268,11 +270,16 @@ main' postLoadMode dflags0 args flagWarnings = do
liftIO $ dumpFinalStats dflags6
-ghciUI :: [(FilePath, Maybe Phase)] -> Maybe [String] -> Ghc ()
+ghciUI :: HscEnv -> DynFlags -> [(FilePath, Maybe Phase)] -> Maybe [String]
+ -> Ghc ()
#if !defined(GHCI)
-ghciUI _ _ = throwGhcException (CmdLineError "not built for interactive use")
+ghciUI _ _ _ _ =
+ throwGhcException (CmdLineError "not built for interactive use")
#else
-ghciUI = interactiveUI defaultGhciSettings
+ghciUI hsc_env dflags0 srcs maybe_expr = do
+ dflags1 <- liftIO (initializePlugins hsc_env dflags0)
+ _ <- GHC.setSessionDynFlags dflags1
+ interactiveUI defaultGhciSettings srcs maybe_expr
#endif
-- -----------------------------------------------------------------------------