Commit bc95fedc authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan Committed by Ben Gamari

Error message and doc improvements for #14335

- Show a more friendly error message when -fplugin is used with
  -fexternal-interpreter

- Add a few words to users guide about the interaction with -fplugin and
  -fexternal-interpreter

- Update test for #14335

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14335

Differential Revision: https://phabricator.haskell.org/D4456
parent 98c7749c
......@@ -57,6 +57,7 @@ import Outputable
import Exception
import Hooks
import Control.Monad ( when, unless )
import Data.Maybe ( mapMaybe )
import GHC.Exts ( unsafeCoerce# )
......@@ -96,7 +97,9 @@ initializePlugins hsc_env df
loadPlugins :: HscEnv -> IO [LoadedPlugin]
loadPlugins hsc_env
= do { plugins <- mapM (loadPlugin hsc_env) to_load
= do { unless (null to_load) $
checkExternalInterpreter hsc_env
; plugins <- mapM loadPlugin to_load
; return $ zipWith attachOptions to_load plugins }
where
dflags = hsc_dflags hsc_env
......@@ -107,11 +110,22 @@ loadPlugins hsc_env
options = [ option | (opt_mod_nm, option) <- pluginModNameOpts dflags
, opt_mod_nm == mod_nm ]
loadPlugin :: HscEnv -> ModuleName -> IO Plugin
loadPlugin = loadPlugin' (mkVarOcc "plugin") pluginTyConName
loadPlugin = loadPlugin' (mkVarOcc "plugin") pluginTyConName hsc_env
loadFrontendPlugin :: HscEnv -> ModuleName -> IO FrontendPlugin
loadFrontendPlugin = loadPlugin' (mkVarOcc "frontendPlugin") frontendPluginTyConName
loadFrontendPlugin hsc_env mod_name = do
checkExternalInterpreter hsc_env
loadPlugin' (mkVarOcc "frontendPlugin") frontendPluginTyConName
hsc_env mod_name
-- #14335
checkExternalInterpreter :: HscEnv -> IO ()
checkExternalInterpreter hsc_env =
when (gopt Opt_ExternalInterpreter dflags) $
throwCmdLineError $ showSDoc dflags $
text "Plugins require -fno-external-interpreter"
where
dflags = hsc_dflags hsc_env
loadPlugin' :: OccName -> Name -> HscEnv -> ModuleName -> IO a
loadPlugin' occ_name plugin_name hsc_env mod_name
......
......@@ -185,6 +185,9 @@ the constraint solver. If you feel strongly that any of these
restrictions are too onerous,
:ghc-wiki:`please give the GHC team a shout <MailingListsAndIRC>`.
Plugins do not work with ``-fexternal-interpreter``. If you need to run plugins
with ``-fexternal-interpreter`` let GHC developers know in :ghc-ticket:`14335`.
.. _using-compiler-plugins:
Using compiler plugins
......
......@@ -52,8 +52,3 @@ T12567a:
"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make T12567a.hs -package-db simple-plugin/pkg.T12567a/local.package.conf -hide-all-plugin-packages -plugin-package simple-plugin 1>&2
"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make T12567a.hs -package-db simple-plugin/pkg.T12567a/local.package.conf -hide-all-plugin-packages -plugin-package simple-plugin 2>&1 | grep "T12567a.hs, T12567a.o" 1>&2
"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) --make T12567b.hs -package-db simple-plugin/pkg.T12567a/local.package.conf -hide-all-plugin-packages -plugin-package simple-plugin 1>&2
.PHONY: T14335
T14335:
"$(TEST_HC)" $(TEST_HC_OPTS) $(ghcPluginWayFlags) -fexternal-interpreter --make -v0 plugins01.hs -package-db simple-plugin/pkg.plugins01/local.package.conf -fplugin Simple.Plugin -fplugin-opt Simple.Plugin:Irrelevant_Option -hide-all-plugin-packages -plugin-package simple-plugin
./plugins01
<command line>: Plugins require -fno-external-interpreter
......@@ -70,6 +70,7 @@ test('T12567a',
test('T14335',
[extra_files(['simple-plugin/', 'plugins01.hs']),
pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins01 TOP={top}'),
expect_broken(14335)],
run_command, ['$MAKE -s --no-print-directory T14335'])
pre_cmd('$MAKE -s --no-print-directory -C simple-plugin package.plugins01 TOP={top}')],
compile_fail,
['-package-db simple-plugin/pkg.plugins01/local.package.conf -fplugin Simple.Plugin \
-fexternal-interpreter -package simple-plugin ' + config.plugin_way_flags])
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