compiler: introduce DynFlags plugins
They have type '[CommandLineOpts] -> Maybe (DynFlags -> IO DynFlags)'. All plugins that supply a non-Nothing 'dynflagsPlugin' will see their updates applied to the current DynFlags right after the plugins are loaded. One use case for this is to superseede !1580 for registering hooks from a plugin. Frontend/parser plugins were considered to achieve this but they respectively conflict with how this plugin is going to be used and don't allow overriding/modifying the DynFlags, which is how hooks have to be registered. This commit comes with a test, 'test-hook-plugin', that registers a "fake" meta hook that replaces TH expressions with the 0 integer literal.
Showing
- compiler/main/DynamicLoading.hs 5 additions, 1 deletioncompiler/main/DynamicLoading.hs
- compiler/main/Plugins.hs 8 additions, 0 deletionscompiler/main/Plugins.hs
- docs/users_guide/8.10.1-notes.rst 6 additions, 0 deletionsdocs/users_guide/8.10.1-notes.rst
- docs/users_guide/extending_ghc.rst 106 additions, 0 deletionsdocs/users_guide/extending_ghc.rst
- testsuite/tests/plugins/all.T 10 additions, 0 deletionstestsuite/tests/plugins/all.T
- testsuite/tests/plugins/hooks-plugin/Hooks/Plugin.hs 34 additions, 0 deletionstestsuite/tests/plugins/hooks-plugin/Hooks/Plugin.hs
- testsuite/tests/plugins/hooks-plugin/Makefile 18 additions, 0 deletionstestsuite/tests/plugins/hooks-plugin/Makefile
- testsuite/tests/plugins/hooks-plugin/Setup.hs 2 additions, 0 deletionstestsuite/tests/plugins/hooks-plugin/Setup.hs
- testsuite/tests/plugins/hooks-plugin/hooks-plugin.cabal 9 additions, 0 deletionstestsuite/tests/plugins/hooks-plugin/hooks-plugin.cabal
- testsuite/tests/plugins/test-hooks-plugin.hs 6 additions, 0 deletionstestsuite/tests/plugins/test-hooks-plugin.hs
- testsuite/tests/plugins/test-hooks-plugin.stdout 1 addition, 0 deletionstestsuite/tests/plugins/test-hooks-plugin.stdout
testsuite/tests/plugins/test-hooks-plugin.hs
0 → 100644
Please register or sign in to comment