[commit: ghc] master: Disable package auto-hiding if -hide-all-packages is passed (edff1ef)
git at git.haskell.org
git at git.haskell.org
Tue Aug 5 10:15:30 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/edff1efa74edcfa9db0010ae92e1e159ecb60b7e/ghc
>---------------------------------------------------------------
commit edff1efa74edcfa9db0010ae92e1e159ecb60b7e
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date: Thu Jul 31 18:11:22 2014 +0100
Disable package auto-hiding if -hide-all-packages is passed
Summary:
This is in preparation for thinning/renaming package arguments, which allow
users to rename modules of packages they import. In situations like this,
it may be desirable to load multiple copies of a package at different versions
explicitly under different names.
Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, simonmar, hvr, austin
Subscribers: simonmar, relrod, ezyang, carter
Differential Revision: https://phabricator.haskell.org/D106
>---------------------------------------------------------------
edff1efa74edcfa9db0010ae92e1e159ecb60b7e
compiler/main/Packages.lhs | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/compiler/main/Packages.lhs b/compiler/main/Packages.lhs
index c240956e..5973bc5 100644
--- a/compiler/main/Packages.lhs
+++ b/compiler/main/Packages.lhs
@@ -78,12 +78,18 @@ import qualified Data.Set as Set
-- provide.
--
-- The package state is computed by 'initPackages', and kept in DynFlags.
+-- It is influenced by various package flags:
--
--- * @-package <pkg>@ causes @<pkg>@ to become exposed, and all other packages
--- with the same name to become hidden.
+-- * @-package <pkg>@ and @-package-id <pkg>@ cause @<pkg>@ to become exposed.
+-- If @-hide-all-packages@ was not specified, these commands also cause
+-- all other packages with the same name to become hidden.
--
-- * @-hide-package <pkg>@ causes @<pkg>@ to become hidden.
--
+-- * (there are a few more flags, check below for their semantics)
+--
+-- The package state has the following properties.
+--
-- * Let @exposedPackages@ be the set of packages thus exposed.
-- Let @depExposedPackages@ be the transitive closure from @exposedPackages@ of
-- their dependencies.
@@ -401,9 +407,12 @@ applyPackageFlag dflags unusable pkgs flag =
where
-- When a package is requested to be exposed, we hide all other
- -- packages with the same name.
+ -- packages with the same name if -hide-all-packages was not specified.
+ -- If it was specified, we expect users to not try to expose a package
+ -- multiple times, so don't hide things.
hideAll name ps = map maybe_hide ps
where maybe_hide p
+ | gopt Opt_HideAllPackages dflags = p
| pkgName (sourcePackageId p) == name = p {exposed=False}
| otherwise = p
@@ -475,10 +484,12 @@ packageFlagErr dflags flag reasons
-- that is already exposed. This just makes it non-fatal to have two
-- versions of a package exposed, which can happen if you install a
-- later version of a package in the user database, for example.
+-- However, don't do this if @-hide-all-packages@ was passed.
--
hideOldPackages :: DynFlags -> [PackageConfig] -> IO [PackageConfig]
hideOldPackages dflags pkgs = mapM maybe_hide pkgs
where maybe_hide p
+ | gopt Opt_HideAllPackages dflags = return p
| not (exposed p) = return p
| (p' : _) <- later_versions = do
debugTraceMsg dflags 2 $
More information about the ghc-commits
mailing list