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 important 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.

(cherry picked from commit c6bd1d4)
  • Loading branch information
dcoutts authored and 23Skidoo committed Oct 19, 2016
1 parent 0bae317 commit 329f7ac
Show file tree
Hide file tree
Showing 2 changed files with 9 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 @@ -725,6 +725,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
&& ghcVersion < Version [7,8] []
then toFlag sharedLibInstallPath
else mempty,
ghcOptHideAllPackages = toFlag True,
ghcOptNoAutoLinkPackages = toFlag True,
ghcOptPackageDBs = withPackageDB lbi,
ghcOptPackages = toNubListR $
Expand Down
11 changes: 8 additions & 3 deletions Cabal/Distribution/Simple/GHC/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE PatternGuards #-}

-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Simple.GHC.Internal
Expand Down Expand Up @@ -196,8 +197,11 @@ configureToolchain implInfo ghcProg ghcInfo =
withTempFile tempDir ".o" $ \testofile testohnd -> do
hPutStrLn testchnd "int foo() { return 0; }"
hClose testchnd; hClose testohnd
rawSystemProgram verbosity ghcProg ["-c", testcfile,
"-o", testofile]
rawSystemProgram verbosity ghcProg
[ "-hide-all-packages"
, "-c", testcfile
, "-o", testofile
]
withTempFile tempDir ".o" $ \testofile' testohnd' ->
do
hClose testohnd'
Expand Down Expand Up @@ -341,6 +345,7 @@ componentCcGhcOptions verbosity implInfo lbi bi clbi pref filename =

ghcOptCppIncludePath = toNubListR $ [autogenModulesDir lbi, odir]
++ PD.includeDirs bi,
ghcOptHideAllPackages= toFlag True,
ghcOptPackageDBs = withPackageDB lbi,
ghcOptPackages = toNubListR $ mkGhcOptPackages clbi,
ghcOptCcOptions = toNubListR $
Expand All @@ -366,12 +371,12 @@ componentGhcOptions :: Verbosity -> LocalBuildInfo
componentGhcOptions verbosity lbi bi clbi odir =
mempty {
ghcOptVerbosity = toFlag verbosity,
ghcOptHideAllPackages = toFlag True,
ghcOptCabal = toFlag True,
ghcOptThisUnitId = case clbi of
LibComponentLocalBuildInfo { componentCompatPackageKey = pk }
-> toFlag pk
_ -> Mon.mempty,
ghcOptHideAllPackages = toFlag True,
ghcOptPackageDBs = withPackageDB lbi,
ghcOptPackages = toNubListR $ mkGhcOptPackages clbi,
ghcOptSplitObjs = toFlag (splitObjs lbi),
Expand Down

0 comments on commit 329f7ac

Please sign in to comment.