Skip to content

Allow registering (Source)Plugins through the GHC API

One might expect to be able to load plugins through the GHC API by doing something like:

runGHC $ do
  dflags <- getSessionDynFlags
  setSessionDynFlags dflags { plugins = [LoadedPlugin some_plugin _conjure_up_modiface []] }

but this doesn't actually work because the plugins field in DynFlags is used as a cache and overwritten by initializePlugins whenever plugins loaded through the command-line need reloading. Not to mention that there isn't a meaningful way to fill the _conjure_up_modiface hole AFAIK.

While in principle it might be possible to use source plugins via the API right now by messing with the exposed cmdline flags the right way it feels much cleaner to just have a new type of plugin that can be added to GHC right through the API.

Trac metadata
Trac field Value
Version 8.7
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by DanielG
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information