[commit: ghc] ghc-8.4: Add support for opting out of package environments (84c250b)
git at git.haskell.org
git at git.haskell.org
Mon Oct 8 21:32:34 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.4
Link : http://ghc.haskell.org/trac/ghc/changeset/84c250b41b22604a830a1a8152bad8167a8b0db1/ghc
>---------------------------------------------------------------
commit 84c250b41b22604a830a1a8152bad8167a8b0db1
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Sun May 13 18:37:18 2018 -0400
Add support for opting out of package environments
This implements the first part proposed in #13753:
Define a special magic "null" environment, which instructs GHC to ignore
any package environment files. To this end, I propose to use the name
`-` (i.e. a single dash), as that is more portable than using the empty
string for environment variables. In other words, a
- `-package-env -` CLI flag, or a
- `GHC_ENVIRONMENT=-` env var (unless a `-package-env` flag is present)
would inhibit GHC from looking up and interpreting any package
environment files from the filesystem; this is the equivalent of
`-ignore-dot-ghci` for package environment files.
Reviewers: bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie, carter
GHC Trac Issues: #13753
Differential Revision: https://phabricator.haskell.org/D4690
(cherry picked from commit 8f3c149d94814e4f278b08c562f06fc257eb3c43)
>---------------------------------------------------------------
84c250b41b22604a830a1a8152bad8167a8b0db1
compiler/main/DynFlags.hs | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 5b512a1..63bf467 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -4825,12 +4825,14 @@ interpretPackageEnv :: DynFlags -> IO DynFlags
interpretPackageEnv dflags = do
mPkgEnv <- runMaybeT $ msum $ [
getCmdLineArg >>= \env -> msum [
- probeEnvFile env
+ probeNullEnv env
+ , probeEnvFile env
, probeEnvName env
, cmdLineError env
]
, getEnvVar >>= \env -> msum [
- probeEnvFile env
+ probeNullEnv env
+ , probeEnvFile env
, probeEnvName env
, envError env
]
@@ -4843,6 +4845,9 @@ interpretPackageEnv dflags = do
Nothing ->
-- No environment found. Leave DynFlags unchanged.
return dflags
+ Just "-" -> do
+ -- Explicitly disabled environment file. Leave DynFlags unchanged.
+ return dflags
Just envfile -> do
content <- readFile envfile
putLogMsg dflags NoReason SevInfo noSrcSpan
@@ -4872,6 +4877,10 @@ interpretPackageEnv dflags = do
guard =<< liftMaybeT (doesFileExist path)
return path
+ probeNullEnv :: FilePath -> MaybeT IO FilePath
+ probeNullEnv "-" = return "-"
+ probeNullEnv _ = mzero
+
parseEnvFile :: FilePath -> String -> DynP ()
parseEnvFile envfile = mapM_ parseEntry . lines
where
More information about the ghc-commits
mailing list