Commit 930a525a authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan

Abort the build when a Core plugin pass is specified in stage1 compiler

This also makes the behavior the same with frontend plugin errors --
frontend was failing with an exception (`CmdLineError`) while the
simplifier was just ignoring plugins. Now we abort with `CmdLineError`
in both cases with a slightly improved error message.

Test Plan:
- add tests (will add tests once #12197 is implemented)
- validate (done)

Reviewers: austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2334

GHC Trac Issues: #11690
parent c56f8bd0
......@@ -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
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment