[commit: ghc] ghc-8.0: Fix handling of package-db entries in .ghc.environment files, etc. (b688f00)
git at git.haskell.org
git at git.haskell.org
Wed Aug 31 23:23:40 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.0
Link : http://ghc.haskell.org/trac/ghc/changeset/b688f0056a1694bb0db3ca2b84ab5505ba9947d7/ghc
>---------------------------------------------------------------
commit b688f0056a1694bb0db3ca2b84ab5505ba9947d7
Author: Duncan Coutts <duncan at well-typed.com>
Date: Tue Aug 30 16:59:17 2016 -0400
Fix handling of package-db entries in .ghc.environment files, etc.
Previously interpreting the content of the .ghc.env files was done
after the step that loaded the available package dbs. This meant that
setting the package db flags was ineffective. This patch moves
interpreting the env files before loading of the package dbs.
Also, the package-db entries refer to files. Allow spaces in these file
names. Also treat as comments lines beginning with "--".
These are pretty minor fixes in a feature that up 'til now has been
essentially unused (witness no bug report about it), so there's very
low risk here. If we can get this into 8.0.2 then cabal can start
generating the .ghc.environment files, otherwise it cannot as it needs
the working package-db entries, to be able to refer to local package
dbs in the build tree (or cabal nix store).
Test Plan:
Manually create example .ghc.env files
run ghci; :show packages
Done this. It works.
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2476
(cherry picked from commit ef784c551ef9b64c3c0b32c73f54bbdb747a8188)
>---------------------------------------------------------------
b688f0056a1694bb0db3ca2b84ab5505ba9947d7
compiler/main/DynFlags.hs | 4 +++-
compiler/main/Packages.hs | 7 +++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 7582e11..09522ab 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -4359,13 +4359,15 @@ interpretPackageEnv dflags = do
parseEnvFile envfile = mapM_ parseEntry . lines
where
parseEntry str = case words str of
- ["package-db", db] -> addPkgConfRef (PkgConfFile (envdir </> db))
+ ("package-db": _) -> addPkgConfRef (PkgConfFile (envdir </> db))
-- relative package dbs are interpreted relative to the env file
where envdir = takeDirectory envfile
+ db = drop 11 str
["clear-package-db"] -> clearPkgConf
["global-package-db"] -> addPkgConfRef GlobalPkgConf
["user-package-db"] -> addPkgConfRef UserPkgConf
["package-id", pkgid] -> exposePackageId pkgid
+ (('-':'-':_):_) -> return () -- comments
-- and the original syntax introduced in 7.10:
[pkgid] -> exposePackageId pkgid
[] -> return ()
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
index 4a09ce6..eca0890 100644
--- a/compiler/main/Packages.hs
+++ b/compiler/main/Packages.hs
@@ -342,7 +342,8 @@ listPackageConfigMap dflags = eltsUDFM (pkgIdMap (pkgState dflags))
-- 'pkgState' in 'DynFlags' and return a list of packages to
-- link in.
initPackages :: DynFlags -> IO (DynFlags, [UnitId])
-initPackages dflags = do
+initPackages dflags0 = do
+ dflags <- interpretPackageEnv dflags0
pkg_db <-
case pkgDatabase dflags of
Nothing -> readPackageConfigs dflags
@@ -884,9 +885,7 @@ mkPackageState
UnitId) -- this package, might be modified if the current
-- package is a wired-in package.
-mkPackageState dflags0 dbs preload0 = do
- dflags <- interpretPackageEnv dflags0
-
+mkPackageState dflags dbs preload0 = do
-- Compute the unit id
let this_package = thisPackage dflags
More information about the ghc-commits
mailing list