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 /compiler/GHC/Linker | |
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 'compiler/GHC/Linker')
-rw-r--r-- | compiler/GHC/Linker/Loader.hs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/compiler/GHC/Linker/Loader.hs b/compiler/GHC/Linker/Loader.hs index 2af6f4dfe1..80e303b046 100644 --- a/compiler/GHC/Linker/Loader.hs +++ b/compiler/GHC/Linker/Loader.hs @@ -723,7 +723,6 @@ getLinkDeps hsc_env hpt pls replace_osuf span mods let pkg = moduleUnit mod deps = mi_deps iface - home_unit = hsc_home_unit hsc_env pkg_deps = dep_direct_pkgs deps (boot_deps, mod_deps) = flip partitionWith (Set.toList (dep_direct_mods deps)) $ @@ -735,10 +734,11 @@ getLinkDeps hsc_env hpt pls replace_osuf span mods acc_mods' = addListToUniqDSet acc_mods (moduleName mod : mod_deps) acc_pkgs' = addListToUniqDSet acc_pkgs (Set.toList pkg_deps) -- - if not (isHomeUnit home_unit pkg) - then follow_deps mods acc_mods (addOneToUniqDSet acc_pkgs' (toUnitId pkg)) - else follow_deps (map (mkHomeModule home_unit) mod_deps' ++ mods) - acc_mods' acc_pkgs' + case ue_home_unit (hsc_unit_env hsc_env) of + Just home_unit + | isHomeUnit home_unit pkg + -> follow_deps (map (mkHomeModule home_unit) mod_deps' ++ mods) acc_mods' acc_pkgs' + _ -> follow_deps mods acc_mods (addOneToUniqDSet acc_pkgs' (toUnitId pkg)) where msg = text "need to link module" <+> ppr mod <+> text "due to use of Template Haskell" @@ -765,12 +765,14 @@ getLinkDeps hsc_env hpt pls replace_osuf span mods | otherwise = do -- It's not in the HPT because we are in one shot mode, -- so use the Finder to get a ModLocation... - let fc = hsc_FC hsc_env - let home_unit = hsc_home_unit hsc_env - let dflags = hsc_dflags hsc_env - let fopts = initFinderOpts dflags - mb_stuff <- findHomeModule fc fopts home_unit mod_name - case mb_stuff of + case ue_home_unit (hsc_unit_env hsc_env) of + Nothing -> no_obj mod_name + Just home_unit -> do + let fc = hsc_FC hsc_env + let dflags = hsc_dflags hsc_env + let fopts = initFinderOpts dflags + mb_stuff <- findHomeModule fc fopts home_unit mod_name + case mb_stuff of Found loc mod -> found loc mod _ -> no_obj mod_name where |