diff options
author | Aaron Allen <aaron@flipstone.com> | 2022-06-19 21:10:57 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-05-05 18:42:31 -0400 |
commit | 18a7d03d46706d2217235d26a72e6f1e82c62192 (patch) | |
tree | 4a5f944dd1071effdafb8ade44d7682c00aa307b /ghc | |
parent | a5174a591b890544b065a3fcb5923f51e61283f2 (diff) | |
download | haskell-18a7d03d46706d2217235d26a72e6f1e82c62192.tar.gz |
Rework plugin initialisation points
In general this patch pushes plugin initialisation points to earlier in
the pipeline. As plugins can modify the `HscEnv`, it's imperative that
the plugins are initialised as soon as possible and used thereafter.
For example, there are some new tests which modify hsc_logger and other
hooks which failed to fire before (and now do)
One consequence of this change is that the error for specifying the
usage of a HPT plugin from the command line has changed, because it's
now attempted to be loaded at initialisation rather than causing a
cyclic module import.
Closes #21279
Co-authored-by: Matthew Pickering <matthewtpickering@gmail.com>
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/Main.hs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs index ef3de102c0..5b1f33bb4e 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -41,7 +41,7 @@ import GHC.Platform.Host import GHCi.UI ( interactiveUI, ghciWelcomeMsg, defaultGhciSettings ) #endif -import GHC.Runtime.Loader ( loadFrontendPlugin ) +import GHC.Runtime.Loader ( loadFrontendPlugin, initializeSessionPlugins ) import GHC.Unit.Env import GHC.Unit (UnitId, homeUnitDepends) @@ -257,16 +257,23 @@ main' postLoadMode units dflags0 args flagWarnings = do -- we've finished manipulating the DynFlags, update the session _ <- GHC.setSessionDynFlags dflags5 dflags6 <- GHC.getSessionDynFlags - hsc_env <- GHC.getSession + + -- Must do this before loading plugins + liftIO $ initUniqSupply (initialUnique dflags6) (uniqueIncrement dflags6) + + -- Initialise plugins here because the plugin author might already expect this + -- subsequent call to `getLogger` to be affected by a plugin. + initializeSessionPlugins + hsc_env <- getSession logger <- getLogger + ---------------- Display configuration ----------- case verbosity dflags6 of v | v == 4 -> liftIO $ dumpUnitsSimple hsc_env | v >= 5 -> liftIO $ dumpUnits hsc_env | otherwise -> return () - liftIO $ initUniqSupply (initialUnique dflags6) (uniqueIncrement dflags6) ---------------- Final sanity checking ----------- liftIO $ checkOptions postLoadMode dflags6 srcs objs units |