compiler: introduce DynFlags plugins
They have type [CommandLineOpts] -> Maybe (DynFlags -> IO DynFlags)
.
All plugins that supply a non-Nothing
dynflagsPlugin
will see their
updates applied to the current DynFlags
right after the plugins are
loaded.
One use case for this is to superseede !1580 (closed) for registering hooks
from a plugin. Frontend/parser plugins were considered to achieve this
but they respectively conflict with how this plugin field is going to be used
(it's not to take over with a new frontend, I just need to register a hook)
and don't allow overriding/modifying the DynFlags
, which is how hooks have
to be registered.
This commit comes with a test, test-hook-plugin
, that registers a "fake"
meta hook that replaces TH expressions with the 0
integer literal.