Plugins should be able to write data to extensible interface fields during the pipeline
Motivation
Implemented in !3758
Currently, extensible interface files (https://gitlab.haskell.org/ghc/ghc/-/wikis/Extensible-Interface-Files) are able to either have fields added by GHC itself, or by users of the GHC API - but the latter case only allows this to be done after the .hi
exists on disk.
These extensible fields are significantly more useful if plugins are also able to add data to the interface while the pipeline is still in progress.
Proposal
Add functions for plugins to write to a set of interface fields that will be later written to the disk, alongside the rest of the interface file:
registerInterfaceData :: Binary a => FieldName -> HscEnv -> a -> IO ()
registerInterfaceDataWith :: FieldName -> HscEnv -> (BinHandle -> IO ()) -> IO ()
unregisterInterfaceData :: FieldName -> HscEnv -> IO ()
Note that Binary
and BinHandle
are from GHC's internal binary implementation.
These data are then stored serialised in an IORef
within the HscEnv
and written with the ModIface
.