summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/main/DynamicLoading.hs23
-rw-r--r--compiler/simplCore/SimplCore.hs8
-rw-r--r--ghc/Main.hs5
3 files changed, 33 insertions, 3 deletions
diff --git a/compiler/main/DynamicLoading.hs b/compiler/main/DynamicLoading.hs
index e7a2b953ed..2b2365f87f 100644
--- a/compiler/main/DynamicLoading.hs
+++ b/compiler/main/DynamicLoading.hs
@@ -19,6 +19,8 @@ module DynamicLoading (
getValueSafely,
getHValueSafely,
lessUnsafeCoerce
+#else
+ pluginError,
#endif
) where
@@ -55,6 +57,16 @@ import Hooks
import Data.Maybe ( mapMaybe )
import GHC.Exts ( unsafeCoerce# )
+#else
+
+import Module ( ModuleName, moduleNameString )
+import Panic
+
+import Data.List ( intercalate )
+
+#endif
+
+#ifdef GHCI
loadPlugins :: HscEnv -> IO [(ModuleName, Plugin, [CommandLineOption])]
loadPlugins hsc_env
@@ -243,4 +255,15 @@ throwCmdLineErrorS dflags = throwCmdLineError . showSDoc dflags
throwCmdLineError :: String -> IO a
throwCmdLineError = throwGhcExceptionIO . CmdLineError
+
+#else
+
+pluginError :: [ModuleName] -> a
+pluginError modnames = throwGhcException (CmdLineError msg)
+ where
+ msg = "not built for interactive use - can't load plugins ("
+ -- module names are not z-encoded
+ ++ intercalate ", " (map moduleNameString modnames)
+ ++ ")"
+
#endif
diff --git a/compiler/simplCore/SimplCore.hs b/compiler/simplCore/SimplCore.hs
index 6884696c97..85ae8cda89 100644
--- a/compiler/simplCore/SimplCore.hs
+++ b/compiler/simplCore/SimplCore.hs
@@ -59,6 +59,8 @@ import qualified GHC.LanguageExtensions as LangExt
#ifdef GHCI
import DynamicLoading ( loadPlugins )
import Plugins ( installCoreToDos )
+#else
+import DynamicLoading ( pluginError )
#endif
{-
@@ -350,7 +352,11 @@ getCoreToDo dflags
addPluginPasses :: [CoreToDo] -> CoreM [CoreToDo]
#ifndef GHCI
-addPluginPasses builtin_passes = return builtin_passes
+addPluginPasses builtin_passes
+ = do { dflags <- getDynFlags
+ ; let pluginMods = pluginModNames dflags
+ ; unless (null pluginMods) (pluginError pluginMods)
+ ; return builtin_passes }
#else
addPluginPasses builtin_passes
= do { hsc_env <- getHscEnv
diff --git a/ghc/Main.hs b/ghc/Main.hs
index 5605438f63..1a6cbebe3c 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -32,6 +32,8 @@ import GHCi.UI ( interactiveUI, ghciWelcomeMsg, defaultGhciSettings )
#ifdef GHCI
import DynamicLoading
import Plugins
+#else
+import DynamicLoading ( pluginError )
#endif
import Module ( ModuleName )
@@ -841,8 +843,7 @@ dumpPackagesSimple dflags = putMsg dflags (pprPackagesSimple dflags)
doFrontend :: ModuleName -> [(String, Maybe Phase)] -> Ghc ()
#ifndef GHCI
-doFrontend _ _ =
- throwGhcException (CmdLineError "not built for interactive use")
+doFrontend modname _ = pluginError [modname]
#else
doFrontend modname srcs = do
hsc_env <- getSession