diff options
-rw-r--r-- | compiler/main/DynamicLoading.hs | 22 | ||||
-rw-r--r-- | docs/users_guide/extending_ghc.rst | 3 | ||||
-rw-r--r-- | testsuite/tests/plugins/Makefile | 5 | ||||
-rw-r--r-- | testsuite/tests/plugins/T14335.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/plugins/T14335.stderr | 1 | ||||
-rw-r--r-- | testsuite/tests/plugins/all.T | 7 |
6 files changed, 27 insertions, 12 deletions
diff --git a/compiler/main/DynamicLoading.hs b/compiler/main/DynamicLoading.hs index 3dc49814cd..90a099f9a7 100644 --- a/compiler/main/DynamicLoading.hs +++ b/compiler/main/DynamicLoading.hs @@ -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 diff --git a/docs/users_guide/extending_ghc.rst b/docs/users_guide/extending_ghc.rst index e49effbd29..12043a0542 100644 --- a/docs/users_guide/extending_ghc.rst +++ b/docs/users_guide/extending_ghc.rst @@ -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 diff --git a/testsuite/tests/plugins/Makefile b/testsuite/tests/plugins/Makefile index 96443c9b32..1ff8d40e8b 100644 --- a/testsuite/tests/plugins/Makefile +++ b/testsuite/tests/plugins/Makefile @@ -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 diff --git a/testsuite/tests/plugins/T14335.hs b/testsuite/tests/plugins/T14335.hs new file mode 100644 index 0000000000..49a0085247 --- /dev/null +++ b/testsuite/tests/plugins/T14335.hs @@ -0,0 +1 @@ +module T14335 where diff --git a/testsuite/tests/plugins/T14335.stderr b/testsuite/tests/plugins/T14335.stderr new file mode 100644 index 0000000000..1f051a79b4 --- /dev/null +++ b/testsuite/tests/plugins/T14335.stderr @@ -0,0 +1 @@ +<command line>: Plugins require -fno-external-interpreter diff --git a/testsuite/tests/plugins/all.T b/testsuite/tests/plugins/all.T index 0e523f0d28..57866371b3 100644 --- a/testsuite/tests/plugins/all.T +++ b/testsuite/tests/plugins/all.T @@ -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]) |