diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-08-05 11:32:17 +0200 |
---|---|---|
committer | Sylvain Henry <sylvain@haskus.fr> | 2020-08-13 09:49:56 -0400 |
commit | ffc0d578ea22de02a68c64c094602701e65d8895 (patch) | |
tree | 168171a5fb54632f5f4fdd1130a31ed730248e73 /compiler/GHC/Runtime | |
parent | cf97889a38edc3314a7b61e6e0b6e6d0f434c8a2 (diff) | |
download | haskell-ffc0d578ea22de02a68c64c094602701e65d8895.tar.gz |
Add HomeUnit type
Since Backpack the "home unit" is much more involved than what it was
before (just an identifier obtained with `-this-unit-id`). Now it is
used in conjunction with `-component-id` and `-instantiated-with` to
configure module instantiations and to detect if we are type-checking an
indefinite unit or compiling a definite one.
This patch introduces a new HomeUnit datatype which is much easier to
understand. Moreover to make GHC support several packages in the same
instances, we will need to handle several HomeUnits so having a
dedicated (documented) type is helpful.
Finally in #14335 we will also need to handle the case where we have no
HomeUnit at all because we are only loading existing interfaces for
plugins which live in a different space compared to units used to
produce target code. Several functions will have to be refactored to
accept "Maybe HomeUnit" parameters instead of implicitly querying the
HomeUnit fields in DynFlags. Having a dedicated type will make this
easier.
Bump haddock submodule
Diffstat (limited to 'compiler/GHC/Runtime')
-rw-r--r-- | compiler/GHC/Runtime/Eval.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Runtime/Linker.hs | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/compiler/GHC/Runtime/Eval.hs b/compiler/GHC/Runtime/Eval.hs index 2ee3143f76..7197710cfb 100644 --- a/compiler/GHC/Runtime/Eval.hs +++ b/compiler/GHC/Runtime/Eval.hs @@ -85,7 +85,7 @@ import GHC.LanguageExtensions import GHC.Types.Unique import GHC.Types.Unique.Supply import GHC.Utils.Monad -import GHC.Unit.Module +import GHC.Unit import GHC.Builtin.Names ( toDynName, pretendNameIsInScope ) import GHC.Builtin.Types ( isCTupleTyConName ) import GHC.Utils.Panic @@ -812,7 +812,7 @@ getContext = withSession $ \HscEnv{ hsc_IC=ic } -> -- its full top-level scope available. moduleIsInterpreted :: GhcMonad m => Module -> m Bool moduleIsInterpreted modl = withSession $ \h -> - if not (isHomeModule (hsc_dflags h) modl) + if notHomeModule (mkHomeUnitFromFlags (hsc_dflags h)) modl then return False else case lookupHpt (hsc_HPT h) (moduleName modl) of Just details -> return (isJust (mi_globals (hm_iface details))) diff --git a/compiler/GHC/Runtime/Linker.hs b/compiler/GHC/Runtime/Linker.hs index 8c05c38c6c..4a3b03e5eb 100644 --- a/compiler/GHC/Runtime/Linker.hs +++ b/compiler/GHC/Runtime/Linker.hs @@ -47,6 +47,7 @@ import GHC.Platform.Ways import GHC.Types.Name import GHC.Types.Name.Env import GHC.Unit.Module +import GHC.Unit.Home import GHC.Data.List.SetOps import GHC.Runtime.Linker.Types (DynLinker(..), PersistentLinkerState(..)) import GHC.Driver.Session @@ -656,7 +657,6 @@ getLinkDeps hsc_env hpt pls replace_osuf span mods ; return (lnks_needed, pkgs_needed) } where dflags = hsc_dflags hsc_env - this_pkg = homeUnit dflags -- The ModIface contains the transitive closure of the module dependencies -- within the current package, *except* for boot modules: if we encounter @@ -682,6 +682,7 @@ getLinkDeps hsc_env hpt pls replace_osuf span mods let pkg = moduleUnit mod deps = mi_deps iface + home_unit = mkHomeUnitFromFlags dflags pkg_deps = dep_pkgs deps (boot_deps, mod_deps) = flip partitionWith (dep_mods deps) $ @@ -694,9 +695,9 @@ getLinkDeps hsc_env hpt pls replace_osuf span mods acc_mods' = addListToUniqDSet acc_mods (moduleName mod : mod_deps) acc_pkgs' = addListToUniqDSet acc_pkgs $ map fst pkg_deps -- - if pkg /= this_pkg + if not (isHomeUnit home_unit pkg) then follow_deps mods acc_mods (addOneToUniqDSet acc_pkgs' (toUnitId pkg)) - else follow_deps (map (mkModule this_pkg) boot_deps' ++ mods) + else follow_deps (map (mkHomeModule home_unit) boot_deps' ++ mods) acc_mods' acc_pkgs' where msg = text "need to link module" <+> ppr mod <+> |