GHC Plugin hook for end of the compilation run
Motivation
I am working on a GHC plugin opentelemetry-plugin
that is used to report module-level build timing to an OpenTelemetry provider, like Honeycomb. I would like to record the number of modules that GHC compiles in a given build. However, it is impossible to determine when compilation ends, and using addFinalizer
does not work because the program exits and GC does not run.
If the GHC plugin interface allowed me to install a hook for plugin cleanup, that would allow me to close the span when compilation is done.
In general, this would allow all plugins the ability to cleanup any resources they should want to cleanup after the program exits.
Proposal
Extending the GHC plugin type with a hook that runs directly after compilation is done. This could be an IO ()
for my own needs, though it may be nice to have an input parameter representing the result of compilation (possibly a Maybe (NonEmpty Error)
?)