summaryrefslogtreecommitdiff
path: root/compiler/main
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2016-01-18 17:32:27 +0100
committerBen Gamari <ben@smart-cactus.org>2016-01-19 00:07:33 +0100
commit240ddd7c39536776e955e881d709bbb039b48513 (patch)
treeb9686cb0e771a268b514a57dc8bec7e31601351c /compiler/main
parentb8abd852d3674cb485490d2b2e94906c06ee6e8f (diff)
downloadhaskell-240ddd7c39536776e955e881d709bbb039b48513.tar.gz
Switch from -this-package-key to -this-unit-id.
A small cosmetic change, but we have to do a bit of work to actually support it: - Cabal submodule update, so that Cabal passes us -this-unit-id when we ask for it. This includes a Cabal renaming to be consistent with Unit ID, which makes ghc-pkg a bit more scrutable. - Build system is updated to use -this-unit-id rather than -this-package-key, to avoid deprecation warnings. Needs a version test so I resurrected the old test we had (sorry rwbarton!) - I've *undeprecated* -package-name, so that we are in the same state as GHC 7.10, since the "correct" flag will have only entered circulation in GHC 8.0. - I removed -package-key. Since we didn't deprecate -package-id I think this should not cause any problems for users; they can just change their code to use -package-id. - The package database is indexed by UNIT IDs, not component IDs. I updated the naming here. - I dropped the signatures field from ExposedModule; nothing was using it, and instantiatedWith from the package database field. - ghc-pkg was updated to use unit ID nomenclature, I removed the -package-key flags but I decided not to add any new flags for now. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: austin, hvr, bgamari Reviewed By: bgamari Subscribers: 23Skidoo, thomie, erikd Differential Revision: https://phabricator.haskell.org/D1780
Diffstat (limited to 'compiler/main')
-rw-r--r--compiler/main/DynFlags.hs45
-rw-r--r--compiler/main/HscTypes.hs4
-rw-r--r--compiler/main/PackageConfig.hs18
-rw-r--r--compiler/main/Packages.hs11
4 files changed, 40 insertions, 38 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index d28dd30773..ea0bc53343 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -1133,8 +1133,7 @@ isNoLink _ = False
-- is used.
data PackageArg =
PackageArg String -- ^ @-package@, by 'PackageName'
- | PackageIdArg String -- ^ @-package-id@, by 'SourcePackageId'
- | UnitIdArg String -- ^ @-package-key@, by 'ComponentId'
+ | UnitIdArg String -- ^ @-package-id@, by 'UnitId'
deriving (Eq, Show)
-- | Represents the renaming that may be associated with an exposed
@@ -1167,7 +1166,6 @@ data TrustFlag
-- | Flags for manipulating packages visibility.
data PackageFlag
= ExposePackage String PackageArg ModRenaming -- ^ @-package@, @-package-id@
- -- and @-package-key@
| HidePackage String -- ^ @-hide-package@
deriving (Eq)
-- NB: equality instance is used by InteractiveUI to test if
@@ -2774,15 +2772,21 @@ package_flags = [
(NoArg $ do removeUserPkgConf
deprecate "Use -no-user-package-db instead")
- , defGhcFlag "package-name" (HasArg $ \name -> do
+ , defGhcFlag "package-name" (HasArg $ \name -> do
+ upd (setUnitId name))
+ -- TODO: Since we JUST deprecated
+ -- -this-package-key, let's keep this
+ -- undeprecated for another cycle.
+ -- Deprecate this eventually.
+ -- deprecate "Use -this-unit-id instead")
+ , defGhcFlag "this-package-key" (HasArg $ \name -> do
upd (setUnitId name)
- deprecate "Use -this-package-key instead")
- , defGhcFlag "this-package-key" (hasArg setUnitId)
- , defFlag "package-id" (HasArg exposePackageId)
+ deprecate "Use -this-unit-id instead")
+ , defGhcFlag "this-unit-id" (hasArg setUnitId)
, defFlag "package" (HasArg exposePackage)
, defFlag "plugin-package-id" (HasArg exposePluginPackageId)
, defFlag "plugin-package" (HasArg exposePluginPackage)
- , defFlag "package-key" (HasArg exposeUnitId)
+ , defFlag "package-id" (HasArg exposePackageId)
, defFlag "hide-package" (HasArg hidePackage)
, defFlag "hide-all-packages" (NoArg (setGeneralFlag Opt_HideAllPackages))
, defFlag "hide-all-plugin-packages" (NoArg (setGeneralFlag Opt_HideAllPluginPackages))
@@ -3860,23 +3864,20 @@ parsePackageFlag flag constr str
return (orig, orig))
tok m = m >>= \x -> skipSpaces >> return x
-exposePackage, exposePackageId, exposeUnitId, hidePackage,
+exposePackage, exposePackageId, hidePackage,
exposePluginPackage, exposePluginPackageId,
ignorePackage,
trustPackage, distrustPackage :: String -> DynP ()
exposePackage p = upd (exposePackage' p)
exposePackageId p =
upd (\s -> s{ packageFlags =
- parsePackageFlag "-package-id" PackageIdArg p : packageFlags s })
+ parsePackageFlag "-package-id" UnitIdArg p : packageFlags s })
exposePluginPackage p =
upd (\s -> s{ pluginPackageFlags =
parsePackageFlag "-plugin-package" PackageArg p : pluginPackageFlags s })
exposePluginPackageId p =
upd (\s -> s{ pluginPackageFlags =
- parsePackageFlag "-plugin-package-id" PackageIdArg p : pluginPackageFlags s })
-exposeUnitId p =
- upd (\s -> s{ packageFlags =
- parsePackageFlag "-package-key" UnitIdArg p : packageFlags s })
+ parsePackageFlag "-plugin-package-id" UnitIdArg p : pluginPackageFlags s })
hidePackage p =
upd (\s -> s{ packageFlags = HidePackage p : packageFlags s })
ignorePackage p =
@@ -4285,18 +4286,34 @@ compilerInfo dflags
("Tables next to code", cGhcEnableTablesNextToCode),
("RTS ways", cGhcRTSWays),
("RTS expects libdw", showBool cGhcRtsWithLibdw),
+ -- Whether or not we support @-dynamic-too@
("Support dynamic-too", showBool $ not isWindows),
+ -- Whether or not we support the @-j@ flag with @--make@.
("Support parallel --make", "YES"),
+ -- Whether or not we support "Foo from foo-0.1-XXX:Foo" syntax in
+ -- installed package info.
("Support reexported-modules", "YES"),
+ -- Whether or not we support extended @-package foo (Foo)@ syntax.
("Support thinning and renaming package flags", "YES"),
+ -- If true, we require that the 'id' field in installed package info
+ -- match what is passed to the @-this-unit-id@ flag for modules
+ -- built in it
("Requires unified installed package IDs", "YES"),
+ -- Whether or not we support the @-this-package-key@ flag. Prefer
+ -- "Uses unit IDs" over it.
("Uses package keys", "YES"),
+ -- Whether or not we support the @-this-unit-id@ flag
+ ("Uses unit IDs", "YES"),
+ -- Whether or not GHC compiles libraries as dynamic by default
("Dynamic by default", showBool $ dYNAMIC_BY_DEFAULT dflags),
+ -- Whether or not GHC was compiled using -dynamic
("GHC Dynamic", showBool dynamicGhc),
+ -- Whether or not GHC was compiled using -prof
("GHC Profiled", showBool rtsIsProfiled),
("Leading underscore", cLeadingUnderscore),
("Debug on", show debugIsOn),
("LibDir", topDir dflags),
+ -- The path of the global package database used by GHC
("Global Package DB", systemPackageConfig dflags)
]
where
diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs
index 6b5458ea79..9b4cd65016 100644
--- a/compiler/main/HscTypes.hs
+++ b/compiler/main/HscTypes.hs
@@ -1229,7 +1229,7 @@ The details are a bit tricky though:
extend the HPT.
* The 'thisPackage' field of DynFlags is *not* set to 'interactive'.
- It stays as 'main' (or whatever -this-package-key says), and is the
+ It stays as 'main' (or whatever -this-unit-id says), and is the
package to which :load'ed modules are added to.
* So how do we arrange that declarations at the command prompt get to
@@ -1238,7 +1238,7 @@ The details are a bit tricky though:
call to initTc in initTcInteractive, which in turn get the module
from it 'icInteractiveModule' field of the interactive context.
- The 'thisPackage' field stays as 'main' (or whatever -this-package-key says.
+ The 'thisPackage' field stays as 'main' (or whatever -this-unit-id says.
* The main trickiness is that the type environment (tcg_type_env) and
fixity envt (tcg_fix_env), now contain entities from all the
diff --git a/compiler/main/PackageConfig.hs b/compiler/main/PackageConfig.hs
index 3fdb0af1d3..b19257bcea 100644
--- a/compiler/main/PackageConfig.hs
+++ b/compiler/main/PackageConfig.hs
@@ -20,7 +20,6 @@ module PackageConfig (
PackageName(..),
Version(..),
defaultPackageConfig,
- componentIdString,
sourcePackageIdString,
packageNameString,
pprPackageConfig,
@@ -41,7 +40,6 @@ import Unique
-- which is similar to a subset of the InstalledPackageInfo type from Cabal.
type PackageConfig = InstalledPackageInfo
- ComponentId
SourcePackageId
PackageName
Module.UnitId
@@ -88,14 +86,11 @@ instance Outputable PackageName where
-- | Pretty-print an 'ExposedModule' in the same format used by the textual
-- installed package database.
pprExposedModule :: (Outputable a, Outputable b) => ExposedModule a b -> SDoc
-pprExposedModule (ExposedModule exposedName exposedReexport exposedSignature) =
+pprExposedModule (ExposedModule exposedName exposedReexport) =
sep [ ppr exposedName
, case exposedReexport of
Just m -> sep [text "from", pprOriginalModule m]
Nothing -> empty
- , case exposedSignature of
- Just m -> sep [text "is", pprOriginalModule m]
- Nothing -> empty
]
-- | Pretty-print an 'OriginalModule' in the same format used by the textual
@@ -107,11 +102,6 @@ pprOriginalModule (OriginalModule originalPackageId originalModuleName) =
defaultPackageConfig :: PackageConfig
defaultPackageConfig = emptyInstalledPackageInfo
-componentIdString :: PackageConfig -> String
-componentIdString pkg = unpackFS str
- where
- ComponentId str = componentId pkg
-
sourcePackageIdString :: PackageConfig -> String
sourcePackageIdString pkg = unpackFS str
where
@@ -127,7 +117,7 @@ pprPackageConfig InstalledPackageInfo {..} =
vcat [
field "name" (ppr packageName),
field "version" (text (showVersion packageVersion)),
- field "id" (ppr componentId),
+ field "id" (ppr unitId),
field "exposed" (ppr exposed),
field "exposed-modules"
(if all isExposedModule exposedModules
@@ -152,7 +142,7 @@ pprPackageConfig InstalledPackageInfo {..} =
]
where
field name body = text name <> colon <+> nest 4 body
- isExposedModule (ExposedModule _ Nothing Nothing) = True
+ isExposedModule (ExposedModule _ Nothing) = True
isExposedModule _ = False
@@ -163,7 +153,7 @@ pprPackageConfig InstalledPackageInfo {..} =
-- #package_naming#
-- Mostly the compiler deals in terms of 'UnitId's, which are md5 hashes
-- of a package ID, keys of its dependencies, and Cabal flags. You're expected
--- to pass in the unit id in the @-this-package-key@ flag. However, for
+-- to pass in the unit id in the @-this-unit-id@ flag. However, for
-- wired-in packages like @base@ & @rts@, we don't necessarily know what the
-- version is, so these are handled specially; see #wired_in_packages#.
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
index cf181046f0..0a8b279374 100644
--- a/compiler/main/Packages.hs
+++ b/compiler/main/Packages.hs
@@ -602,15 +602,11 @@ matchingStr str p
|| str == packageNameString p
matchingId :: String -> PackageConfig -> Bool
-matchingId str p = str == componentIdString p
-
-matchingKey :: String -> PackageConfig -> Bool
-matchingKey str p = str == unitIdString (packageConfigId p)
+matchingId str p = str == unitIdString (packageConfigId p)
matching :: PackageArg -> PackageConfig -> Bool
matching (PackageArg str) = matchingStr str
-matching (PackageIdArg str) = matchingId str
-matching (UnitIdArg str) = matchingKey str
+matching (UnitIdArg str) = matchingId str
sortByVersion :: [PackageConfig] -> [PackageConfig]
sortByVersion = sortBy (flip (comparing packageVersion))
@@ -1159,8 +1155,7 @@ mkModuleToPkgConfAll dflags pkg_db vis_map =
es :: Bool -> [(ModuleName, Map Module ModuleOrigin)]
es e = do
- -- TODO: signature support
- ExposedModule m exposedReexport _exposedSignature <- exposed_mods
+ ExposedModule m exposedReexport <- exposed_mods
let (pk', m', pkg', origin') =
case exposedReexport of
Nothing -> (pk, m, pkg, fromExposedModules e)