Add support for static plugins in shared libraries
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.
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
- 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.