diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-08-06 18:35:06 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-11-20 05:35:42 -0500 |
commit | bdeea37efc76bc22a0d2e17f66dbf2ae8ad556fc (patch) | |
tree | ed1e62d7f2d34e4c77ff650828de872fb8daeb7a /ghc | |
parent | 3d6b78dbd19f9061387c60e553638f9c26839d50 (diff) | |
download | haskell-bdeea37efc76bc22a0d2e17f66dbf2ae8ad556fc.tar.gz |
More support for optional home-unit
This is a preliminary refactoring for #14335 (supporting plugins in
cross-compilers). In many places the home-unit must be optional because
there won't be one available in the plugin environment (we won't be
compiling anything in this environment). Hence we replace "HomeUnit"
with "Maybe HomeUnit" in a few places and we avoid the use of
"hsc_home_unit" (which is partial) in some few others.
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 2 | ||||
-rw-r--r-- | ghc/Main.hs | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 362fe0b40a..58bbf4f6fe 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -2041,7 +2041,7 @@ addModule files = do let dflags = hsc_dflags hsc_env let fopts = initFinderOpts dflags result <- liftIO $ - Finder.findImportedModule fc fopts units home_unit m (ThisPkg (homeUnitId home_unit)) + Finder.findImportedModule fc fopts units (Just home_unit) m (ThisPkg (homeUnitId home_unit)) case result of Found _ _ -> return True _ -> (liftIO $ putStrLn $ diff --git a/ghc/Main.hs b/ghc/Main.hs index 5e6042173f..d00ae72990 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -43,6 +43,7 @@ import GHCi.UI ( interactiveUI, ghciWelcomeMsg, defaultGhciSettings import GHC.Runtime.Loader ( loadFrontendPlugin ) +import GHC.Unit.Env import GHC.Unit.Module ( ModuleName, mkModuleName ) import GHC.Unit.Module.ModIface import GHC.Unit.State ( pprUnits, pprUnitsSimple ) @@ -872,17 +873,17 @@ abiHash :: [String] -- ^ List of module names -> Ghc () abiHash strs = do hsc_env <- getSession - let fc = hsc_FC hsc_env - let home_unit = hsc_home_unit hsc_env - let units = hsc_units hsc_env - let dflags = hsc_dflags hsc_env - let fopts = initFinderOpts dflags + let fc = hsc_FC hsc_env + let mhome_unit = ue_home_unit (hsc_unit_env hsc_env) + let units = hsc_units hsc_env + let dflags = hsc_dflags hsc_env + let fopts = initFinderOpts dflags liftIO $ do let find_it str = do let modname = mkModuleName str - r <- findImportedModule fc fopts units home_unit modname NoPkgQual + r <- findImportedModule fc fopts units mhome_unit modname NoPkgQual case r of Found _ m -> return m _error -> throwGhcException $ CmdLineError $ showSDoc dflags $ |