[GHC] #11194: Frontend plugins

#11194: Frontend plugins -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: feature | Status: new request | Priority: normal | Milestone: Component: GHC API | Version: 7.11 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- A frontend plugin adds a new major mode to GHC, like `--make`, `--abi- hash`, etc. This will be useful for GHC API clients, because GHC's frontend `ghc/Main.hs` handles a lot of plumbing (flag parsing, setting up the session) which otherwise is painful to reimplement in GHC API (worse yet, it rapidly changes between GHC versions). For example, suppose someone wants to reimplement `--make` using the Shake library. They would define a frontend plugin which implements the `--shake` major mode. Here's how it will work: * A frontend plugin is a module which exports a single identifier `frontendPlugin` of type `GhcPlugins.FrontendPlugin`. This data structure has the following form: {{{ type FrontendPluginAction = [CommandLineOption] -> [(String, Maybe Phase)] -> GHC () data FrontendPlugin = FrontendPlugin { frontendPluginAction :: FrontendPluginAction, -- possibly more fields } defaultFrontendPlugin :: FrontendPluginAction -> FrontendPlugin }}} * There is a new major mode, `--frontend Foo.Plugin`, which loads and runs your plugin. You can pass extra flags to the plugin using `-ffrontend- opt`. We reuse the dynamic loading facilities for normal plugin loading. This should be relatively easy to backport. Possible design flex points: 1. Here, you only load the plugin that you actually want to run. You could also imagine loading a plugin adding a new major mode flag. 2. An alternative to having a full-on plugin architecture is to lib-ify most of `ghc/Main.hs`, so that other clients can use it but with different sets of options, etc. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11194 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11194: Frontend plugins -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: feature request | Status: patch Priority: normal | Milestone: Component: GHC API | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1598 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * status: new => patch * differential: => Phab:D1598 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11194#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11194: Frontend plugins
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner: ezyang
Type: feature request | Status: patch
Priority: normal | Milestone:
Component: GHC API | Version: 7.11
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1598
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Edward Z. Yang

#11194: Frontend plugins -------------------------------------+------------------------------------- Reporter: ezyang | Owner: ezyang Type: feature request | Status: closed Priority: normal | Milestone: Component: GHC API | Version: 7.11 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1598 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11194#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC