Skip to content

Commit

Permalink
Make sure ghc ignores any .ghc.environment files
Browse files Browse the repository at this point in the history
When we invoke ghc in Cabal it's impostant that we control the
environment. It's already the case that ghc ignores the .ghc.env files
when we use -hide-all-packages, but there were a few places where we
were not using this.
  • Loading branch information
dcoutts authored and hvr committed Oct 16, 2016
1 parent faa9b86 commit c6bd1d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cabal/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
&& ghcVersion < mkVersion [7,8]
then toFlag sharedLibInstallPath
else mempty,
ghcOptHideAllPackages = toFlag True,
ghcOptNoAutoLinkPackages = toFlag True,
ghcOptPackageDBs = withPackageDB lbi,
ghcOptThisUnitId = case clbi of
Expand Down
10 changes: 7 additions & 3 deletions Cabal/Distribution/Simple/GHC/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,11 @@ configureToolchain _implInfo ghcProg ghcInfo =
withTempFile tempDir ".o" $ \testofile testohnd -> do
hPutStrLn testchnd "int foo() { return 0; }"
hClose testchnd; hClose testohnd
runProgram verbosity ghcProg ["-c", testcfile,
"-o", testofile]
runProgram verbosity ghcProg
[ "-hide-all-packages"
, "-c", testcfile
, "-o", testofile
]
withTempFile tempDir ".o" $ \testofile' testohnd' ->
do
hClose testohnd'
Expand Down Expand Up @@ -271,6 +274,7 @@ componentCcGhcOptions verbosity _implInfo lbi bi clbi odir filename =
,autogenPackageModulesDir lbi
,odir]
++ PD.includeDirs bi,
ghcOptHideAllPackages= toFlag True,
ghcOptPackageDBs = withPackageDB lbi,
ghcOptPackages = toNubListR $ mkGhcOptPackages clbi,
ghcOptCcOptions = toNubListR $
Expand All @@ -294,7 +298,6 @@ componentGhcOptions verbosity lbi bi clbi odir =
-- Respect -v0, but don't crank up verbosity on GHC if
-- Cabal verbosity is requested. For that, use --ghc-option=-v instead!
ghcOptVerbosity = toFlag (min verbosity normal),
ghcOptHideAllPackages = toFlag True,
ghcOptCabal = toFlag True,
ghcOptThisUnitId = case clbi of
LibComponentLocalBuildInfo { componentCompatPackageKey = pk }
Expand All @@ -312,6 +315,7 @@ componentGhcOptions verbosity lbi bi clbi odir =
-> insts
_ -> [],
ghcOptNoCode = toFlag $ componentIsIndefinite clbi,
ghcOptHideAllPackages = toFlag True,
ghcOptPackageDBs = withPackageDB lbi,
ghcOptPackages = toNubListR $ mkGhcOptPackages clbi,
ghcOptSplitObjs = toFlag (splitObjs lbi),
Expand Down

0 comments on commit c6bd1d4

Please sign in to comment.