From c6bd1d407dfb5fb6834e611ded8e253f6784fb98 Mon Sep 17 00:00:00 2001 From: Duncan Coutts Date: Fri, 26 Aug 2016 00:11:51 +0100 Subject: [PATCH] Make sure ghc ignores any .ghc.environment files 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. --- Cabal/Distribution/Simple/GHC.hs | 1 + Cabal/Distribution/Simple/GHC/Internal.hs | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Cabal/Distribution/Simple/GHC.hs b/Cabal/Distribution/Simple/GHC.hs index 4f016f73bef..ede6e533652 100644 --- a/Cabal/Distribution/Simple/GHC.hs +++ b/Cabal/Distribution/Simple/GHC.hs @@ -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 diff --git a/Cabal/Distribution/Simple/GHC/Internal.hs b/Cabal/Distribution/Simple/GHC/Internal.hs index f7a162adcc4..06626755e64 100644 --- a/Cabal/Distribution/Simple/GHC/Internal.hs +++ b/Cabal/Distribution/Simple/GHC/Internal.hs @@ -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' @@ -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 $ @@ -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 } @@ -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),