[GHC] #8050: add a required wrapper around plugin installers

#8050: add a required wrapper around plugin installers ------------------------------------+------------------------------------- Reporter: nfrisby | Owner: Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- While trying to expand [http://www.haskell.org/ghc/docs/7.6.1/html/users_guide/compiler- plugins.html#writing-compiler-plugins the CoreMonad.reinitializeGlobals mechanism], I proposed an alternative that SPJ noted could be more generally useful. The nub of the idea is to require plugins to apply a distinguished function to their installation function. Instead of defining the plugin as {{{ module APlugin (plugin) where import GhcPlugins plugin :: Plugin plugin = defaultPlugin {installCoreToDos = install} install :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo] install = … }}} plugins would be defined as {{{ module APlugin (plugin) where import GhcPlugins plugin :: Plugin plugin = defaultPlugin {installCoreToDos = mkPluginInstaller install} install :: [CommandLineOption] -> [CoreToDo] -> CoreM [CoreToDo] install = install = … }}} The new function `mkPluginInstaller` provides a hook for GHC developers to process the plugin, hidden from the plugin author. For example, it could encapsulate the current `reinitializeGlobals` mechanism. I'm not sure if using an abstract type to enforce that this function is called is necessary, but it's an option. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8050 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8050: add a required wrapper around plugin installers -------------------------------------+------------------------------------ Reporter: nfrisby | Owner: Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): Why can't the call to `mkPluginInstaller` be done by GHC itself, on line 314 of `SimplCore`? Why make the users call it? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8050#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8050: add a required wrapper around plugin installers -------------------------------------+------------------------------------ Reporter: nfrisby | Owner: Type: task | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by nfrisby): Replying to [comment:1 simonpj]:
Why can't the call to `mkPluginInstaller` be done by GHC itself, on line 314 of `SimplCore`? Why make the users call it?
Simon
My objective for `mkPluginInstaller` is generality: GHC can do whatever it needs in order for the plugin to otherwise Just Work. We have one example — as late as some GHC 7.6 installations — where this requires the plugin to be the caller of the `mkPluginInstaller`-esque function. `reinitializeGlobals` ([[Plugins/ReinitializeGlobals|cf]]) only works if it's called by the plugin, not by the compiler. So, for the sake of futureproofness, the plugin must be the caller of `mkPluginInstaller` in order for it to be able to handle issues like the multiple instances of libHSghc. The underlying problem fixed by `reinitializeGlobals` is that multiple libHSghc instances may exist, eg one for the compiler and one for a plugin. Unfortunately, a user-convenient, robust, omni-platform method to prevent multiple instances of libHSghc does not appear to be in the near future. Moreover, it's not clear that such a solution could be permanent, considering the difficulty of handling dynamic linking on the numerous [[Platforms]]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8050#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC