Skip to content

Add support for static plugins in shared libraries

Motivation

GHC supports two kinds of plugins:

  • loaded plugins: loaded from external packages or from the home unit and setup with command-line flags
  • static plugins: setup arbitrarily via ghc-api

Loaded plugins don't work with cross-compilers (#14335) because GHC only supports a single environment which mixes up target and plugin stuff. Making GHC support two environments (one for plugins and one for target code) instead of a single one is a huge undertaking.

Static plugins can't be setup for a stock GHC program: they need to be setup via ghc-api.

Proposal

Support a third kind of plugins: "external static plugins" (better name suggestions welcome)

Principle: support loading of static plugins via shared libraries.

Users pass to GHC:

  • path to the shared library containing the plugin
  • unit-id
  • module name
  • plugin arguments

With loaded plugins, the path to the shared library containing the plugin and the unit-id are inferred from the module name and from package related command-line flags.

With external static plugins, users pass them explicitly. The advantage is that GHC doesn't have to load any unit info or module interface to load the plugins, bypassing #14335.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information