summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-07-28 14:27:09 -0400
committerBen Gamari <ben@well-typed.com>2021-12-09 22:05:36 +0000
commitbcd8b57a5803bf3fc65aa8313576b09d041bff78 (patch)
treeba22be9b39cc688c0fd0c8ad28575654c0911943
parent2fd6e8565be632c58096442b1754793502956480 (diff)
downloadhaskell-wip/T18173.tar.gz
hadrian: Pass -B to Cabal GHC invocationswip/T18173
-rw-r--r--hadrian/src/Hadrian/Oracles/Cabal/Rules.hs35
1 files changed, 26 insertions, 9 deletions
diff --git a/hadrian/src/Hadrian/Oracles/Cabal/Rules.hs b/hadrian/src/Hadrian/Oracles/Cabal/Rules.hs
index 2a17a6ad69..eccabe8263 100644
--- a/hadrian/src/Hadrian/Oracles/Cabal/Rules.hs
+++ b/hadrian/src/Hadrian/Oracles/Cabal/Rules.hs
@@ -15,16 +15,15 @@ import Control.Monad
import Data.Maybe
import Development.Shake
import Distribution.Simple.GHC
-import Distribution.Simple.Program.Builtin
-import Distribution.Simple.Program.Db
+import Distribution.Simple.Program
+import Distribution.Simple.Program.Types
import Distribution.Verbosity
+import Base
import Builder
import Context
import Hadrian.Haskell.Cabal.Parse
import Hadrian.Oracles.Cabal.Type
-import Hadrian.Package
-import Hadrian.Utilities
-- | These oracle rules are used to cache and track answers to the following
-- queries, which are implemented via the Cabal library:
@@ -58,8 +57,15 @@ cabalOracle = do
putVerbose $ "| PackageConfiguration oracle: configuring "
++ quote (pkgName pkg) ++ " (" ++ show stage ++ ")..."
-- Configure the package with the GHC corresponding to the given stage
+ libPath <- stageLibPath stage
hcPath <- builderPath (Ghc CompileHs stage)
hcPkgPath <- builderPath (GhcPkg undefined stage)
+
+ -- Probe versions
+ let verbosity = silent
+ hcVer <- liftIO $ programFindVersion ghcProgram verbosity (hcPath)
+ hcPkgVer <- liftIO $ programFindVersion ghcPkgProgram verbosity (hcPkgPath)
+
-- N.B. the hcPath parameter of `configure` is broken when given an
-- empty ProgramDb. To work around this we manually construct an
-- appropriate ProgramDb.
@@ -67,13 +73,24 @@ cabalOracle = do
-- We also need to pass the path to ghc-pkg, because Cabal cannot
-- guess it (from ghc's path) when it's for a cross-compiler (e.g.,
-- _build/stage0/bin/aarch64-linux-gnu-ghc-pkg).
- let progDb = userSpecifyPath "ghc" hcPath
- $ addKnownProgram ghcProgram
- $ userSpecifyPath "ghc-pkg" hcPkgPath
- $ addKnownProgram ghcPkgProgram
+ let addLibPath cp
+ | Stage0 <- stage = cp
+ | otherwise = cp { programDefaultArgs = [ "-B"++libPath ] }
+ setVersion version cp = cp { programVersion = version }
+
+ hcProg = setVersion hcVer
+ $ addLibPath
+ $ simpleConfiguredProgram "ghc" (UserSpecified hcPath)
+ hcPkgProg =
+ setVersion hcPkgVer
+ $ addLibPath
+ $ simpleConfiguredProgram "ghc-pkg" (UserSpecified hcPkgPath)
+ let progDb = updateProgram hcProg
+ $ updateProgram hcPkgProg
$ emptyProgramDb
+
(compiler, maybePlatform, _pkgdb) <- liftIO $
- configure silent Nothing Nothing progDb
+ configure verbosity Nothing Nothing progDb
let platform = fromMaybe (error msg) maybePlatform
msg = "PackageConfiguration oracle: cannot detect platform"
return $ PackageConfiguration (compiler, platform)