summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-03-20 17:24:34 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-03-29 17:30:47 -0400
commite54500c12de051cb9695728d27c812e5160593ee (patch)
treece6108608acc6903985288084c9d6d15ae37607b /ghc
parentef9c608eba417c59fe45c9edd6a946c59f50b5d2 (diff)
downloadhaskell-e54500c12de051cb9695728d27c812e5160593ee.tar.gz
Store ComponentId details
As far as GHC is concerned, installed package components ("units") are identified by an opaque ComponentId string provided by Cabal. But we don't want to display it to users (as it contains a hash) so GHC queries the database to retrieve some infos about the original source package (name, version, component name). This patch caches these infos in the ComponentId itself so that we don't need to provide DynFlags (which contains installed package informations) to print a ComponentId. In the future we want GHC to support several independent package states (e.g. for plugins and for target code), hence we need to avoid implicitly querying a single global package state.
Diffstat (limited to 'ghc')
-rw-r--r--ghc/GHCi/UI.hs3
-rw-r--r--ghc/Main.hs6
2 files changed, 5 insertions, 4 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index ec70fc037d..2472b80897 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -2345,7 +2345,8 @@ isSafeModule m = do
tallyPkgs dflags deps | not (packageTrustOn dflags) = (S.empty, S.empty)
| otherwise = S.partition part deps
- where part pkg = trusted $ getInstalledPackageDetails dflags pkg
+ where part pkg = trusted $ getInstalledPackageDetails pkgstate pkg
+ pkgstate = pkgState dflags
-----------------------------------------------------------------------------
-- :browse
diff --git a/ghc/Main.hs b/ghc/Main.hs
index 3cec5b6191..3552133891 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -865,9 +865,9 @@ dumpFastStringStats dflags = do
x `pcntOf` y = int ((x * 100) `quot` y) Outputable.<> char '%'
showPackages, dumpPackages, dumpPackagesSimple :: DynFlags -> IO ()
-showPackages dflags = putStrLn (showSDoc dflags (pprPackages dflags))
-dumpPackages dflags = putMsg dflags (pprPackages dflags)
-dumpPackagesSimple dflags = putMsg dflags (pprPackagesSimple dflags)
+showPackages dflags = putStrLn (showSDoc dflags (pprPackages (pkgState dflags)))
+dumpPackages dflags = putMsg dflags (pprPackages (pkgState dflags))
+dumpPackagesSimple dflags = putMsg dflags (pprPackagesSimple (pkgState dflags))
-- -----------------------------------------------------------------------------
-- Frontend plugin support