Sven Tennie pushed to branch wip/supersven/hadrian-cross-stage3 at Glasgow Haskell Compiler / GHC Commits: cfb65334 by Sven Tennie at 2026-02-14T19:44:49+01:00 Fix final ghc-pkg recache run Sage3 cross-compiler's ghc-pkg cannot run on the build host. Resort to a prior stage's ghc-pkg. - - - - - 2 changed files: - hadrian/src/BindistConfig.hs - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== hadrian/src/BindistConfig.hs ===================================== @@ -1,29 +1,33 @@ module BindistConfig where -import Stage -import Oracles.Flag import Expression +import Oracles.Flag -data BindistConfig = BindistConfig { library_stage :: Stage -- ^ The stage compiler which builds the libraries - , executable_stage :: Stage -- ^ The stage compiler which builds the executables - } +data BindistConfig = BindistConfig + { -- | The stage compiler which builds the libraries + library_stage :: Stage, + -- | The stage compiler which builds the executables + executable_stage :: Stage, + -- | Which ghc-pkg to use (`targetBindist`'s + -- ghc-pkg cannot run on the build platform) + use_inplace_ghcPkg :: Bool + } -- | A bindist for when the host = target, non cross-compilation setting. -- Both the libraries and final executables are built with stage1 compiler. normalBindist :: BindistConfig -normalBindist = BindistConfig { library_stage = Stage1, executable_stage = Stage1 } +normalBindist = BindistConfig {library_stage = Stage1, executable_stage = Stage1, use_inplace_ghcPkg = True} -- | A bindist which contains a cross compiler (when host /= target) -- The cross compiler is produced by the stage1 compiler, but then we must compile -- all the boot libraries with the cross compiler (hence stage2 for libraries) crossBindist :: BindistConfig -crossBindist = BindistConfig { library_stage = Stage2, executable_stage = Stage1 } +crossBindist = BindistConfig {library_stage = Stage2, executable_stage = Stage1, use_inplace_ghcPkg = True} -- | A bindist which contains executables for the target, which produce code for the -- target. These are produced as "Stage3" build products, produced by a stage2 cross compiler. -targetBindist :: BindistConfig -targetBindist = BindistConfig { library_stage = Stage2, executable_stage = Stage2 } - +targetBindist :: BindistConfig +targetBindist = BindistConfig {library_stage = Stage2, executable_stage = Stage2, use_inplace_ghcPkg = False} -- | The implicit bindist config, if we don't know any better. implicitBindistConfig :: Action BindistConfig @@ -35,7 +39,7 @@ implicitBindistConfig = do return $ if cross then crossBindist else normalBindist -- | Are we building things in this stage for the final target? -buildingForTarget :: Stage -> Action Bool +buildingForTarget :: Stage -> Action Bool buildingForTarget st = do cfg <- implicitBindistConfig return $ st >= (library_stage cfg) ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -222,9 +222,16 @@ buildBinDistDir dirPrefix root conf@BindistConfig{..} = do -- -- N.B. the ghc-pkg executable may be prefixed with a target triple -- (c.f. #20267). - - ghcPkgName <- programName (vanillaContext executable_stage ghcPkg) - cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache", "--package-db", bindistFilesDir -/- "lib" -/- "package.conf.d" ] + -- + -- For Stage3 cross-compilers (those that are supposed to run on the target + -- platform), we have to resort to a prior stage's ghc-pkg as the final + -- stage can naturally not be executed on our current build host. + if use_inplace_ghcPkg then do + ghcPkgName <- programName (vanillaContext executable_stage ghcPkg) + cmd_ (bindistFilesDir -/- "bin" -/- ghcPkgName) ["recache", "--package-db", bindistFilesDir -/- "lib" -/- "package.conf.d" ] + else do + ghcPkgPath <- builderPath $ GhcPkg Recache library_stage + cmd_ ghcPkgPath ["recache", "--package-db", bindistFilesDir -/- "lib" -/- "package.conf.d" ] need ["docs"] View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cfb653349053053053a9982ee181623f... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cfb653349053053053a9982ee181623f... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Sven Tennie (@supersven)