[commit: ghc] master: Stub out pkgState with non-error, helps with debugging. (ad6d6a7)
git at git.haskell.org
git at git.haskell.org
Fri Apr 17 10:10:27 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/ad6d6a76eeeb9e33a96054f18c1306e9ebafa652/ghc
>---------------------------------------------------------------
commit ad6d6a76eeeb9e33a96054f18c1306e9ebafa652
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date: Mon Apr 6 11:32:14 2015 -0700
Stub out pkgState with non-error, helps with debugging.
Summary:
When we use -dppr-debug, we'll sometimes attempt to
hit the pkgState to give more detailed information. It's pretty
annoying to have this fail because we haven't filled in the
pkgState: we can still get useful debugging information by
printing the raw package key. To avoid this, we just put
in some empty stub pkgState, to be filled in later.
Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D817
>---------------------------------------------------------------
ad6d6a76eeeb9e33a96054f18c1306e9ebafa652
compiler/main/DynFlags.hs | 5 +++--
compiler/main/Packages.hs | 9 +++++++++
compiler/main/Packages.hs-boot | 1 +
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 446381e..094984b 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -157,7 +157,7 @@ import Module
import PackageConfig
import {-# SOURCE #-} Hooks
import {-# SOURCE #-} PrelNames ( mAIN )
-import {-# SOURCE #-} Packages (PackageState)
+import {-# SOURCE #-} Packages (PackageState, emptyPackageState)
import DriverPhases ( Phase(..), phaseInputExt )
import Config
import CmdLineParser
@@ -1480,7 +1480,8 @@ defaultDynFlags mySettings =
packageFlags = [],
packageEnv = Nothing,
pkgDatabase = Nothing,
- pkgState = panic "no package state yet: call GHC.setSessionDynFlags",
+ -- This gets filled in with GHC.setSessionDynFlags
+ pkgState = emptyPackageState,
ways = defaultWays mySettings,
buildTag = mkBuildTag (defaultWays mySettings),
rtsBuildTag = mkBuildTag (defaultWays mySettings),
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
index 985a11a..16ee352 100644
--- a/compiler/main/Packages.hs
+++ b/compiler/main/Packages.hs
@@ -8,6 +8,7 @@ module Packages (
-- * Reading the package config, and processing cmdline args
PackageState(preloadPackages),
+ emptyPackageState,
initPackages,
readPackageConfigs,
getPackageConfRefs,
@@ -287,6 +288,14 @@ data PackageState = PackageState {
installedPackageIdMap :: InstalledPackageIdMap
}
+emptyPackageState :: PackageState
+emptyPackageState = PackageState {
+ pkgIdMap = emptyUFM,
+ preloadPackages = [],
+ moduleNameDb = Map.empty,
+ installedPackageIdMap = Map.empty
+ }
+
type InstalledPackageIdMap = Map InstalledPackageId PackageKey
type InstalledPackageIndex = Map InstalledPackageId PackageConfig
diff --git a/compiler/main/Packages.hs-boot b/compiler/main/Packages.hs-boot
index f2343b6..bac04bc 100644
--- a/compiler/main/Packages.hs-boot
+++ b/compiler/main/Packages.hs-boot
@@ -4,3 +4,4 @@ import {-# SOURCE #-} Module (PackageKey)
import {-# SOURCE #-} DynFlags (DynFlags)
data PackageState
packageKeyPackageIdString :: DynFlags -> PackageKey -> Maybe String
+emptyPackageState :: PackageState
More information about the ghc-commits
mailing list