[Git][ghc/ghc][wip/hadrian-target] hadrian: binary-dist-dir should not be the default target
Zubin pushed to branch wip/hadrian-target at Glasgow Haskell Compiler / GHC Commits: 0e020352 by Zubin Duggal at 2026-07-02T21:53:46+05:30 hadrian: binary-dist-dir should not be the default target Revert behaviour to pre 23c9b6c392f52ec9d7a8618b204ff6b885f5fba2 In 23c9b6c392f52ec9d7a8618b204ff6b885f5fba2, we applied the following behaviour change: ``` hadrian: Build stage 2 cross compilers ... * hadrian: Make binary-dist-dir the default build target. This allows us to have the logic in one place about which libraries/stages to build with cross compilers. Fixes #24192 ``` This is a major regression to development experience, a plain hadrian/build --freeze1 now takes ages because we rebuild all docs (which need to go in the binary dist dir). `binary-dist-dir` is the wrong default target for regular GHC development work Fixes #27445 - - - - - 2 changed files: - hadrian/src/Rules.hs - hadrian/src/Rules/BinaryDist.hs Changes: ===================================== hadrian/src/Rules.hs ===================================== @@ -10,6 +10,7 @@ import qualified Hadrian.Oracles.Path import qualified Hadrian.Oracles.TextFile import qualified Hadrian.Haskell.Hash +import BindistConfig import Expression import qualified Oracles.Flavour import qualified Oracles.ModuleFiles @@ -32,17 +33,49 @@ import Settings.Program (programContext) import Target import UserSettings --- | This rule defines what the default build configuration is when no targets --- are selected. +-- | This rule calls 'need' on all top-level build targets that Hadrian builds +-- by default, respecting the 'finalStage' flag. topLevelTargets :: Rules () topLevelTargets = action $ do - let targets = ["binary-dist-dir"] + verbosity <- getVerbosity + forM_ [ Stage1, Stage2, Stage3] $ \stage -> do + when (verbosity >= Verbose) $ do + (libraries, programs) <- partition isLibrary <$> stagePackages stage + libNames <- mapM (name stage) libraries + pgmNames <- mapM (name stage) programs + let stageHeader t ps = + "| Building " ++ show stage ++ " " + ++ t ++ ": " ++ intercalate ", " ps + putInfo . unlines $ + [ stageHeader "libraries" libNames + , stageHeader "programs" pgmNames ] + let buildStages = [ s | s <- allStages, s < finalStage ] + targets <- concatForM buildStages $ \stage -> do + packages <- stagePackages stage + mapM (path stage) packages + + -- For cross compilers, also build the target (stage 2) libraries. + cfg <- implicitBindistConfig + lib_targets <- if executable_stage cfg < finalStage + then map snd . fst <$> Rules.BinaryDist.bindistPackageTargets cfg + else return [] -- Why we need wrappers: https://gitlab.haskell.org/ghc/ghc/issues/16534. root <- buildRoot let wrappers = [ root -/- ("ghc-" ++ stageString s) | s <- [Stage1, Stage2, Stage3] , s < finalStage ] - need (targets ++ wrappers) + need (targets ++ lib_targets ++ wrappers) + where + -- either the package database config file for libraries or + -- the programPath for programs. However this still does + -- not support multiple targets, where a cabal package has + -- a library /and/ a program. + path :: Stage -> Package -> Action FilePath + path stage pkg | isLibrary pkg = pkgConfFile (vanillaContext stage pkg) + | otherwise = programPath =<< programContext stage pkg + name :: Stage -> Package -> Action String + name stage pkg | isLibrary pkg = return (pkgName pkg) + | otherwise = programName (vanillaContext stage pkg) -- | Return the list of targets associated with a given 'Stage' and 'Package'. packageTargets :: Stage -> Package -> Action [FilePath] ===================================== hadrian/src/Rules/BinaryDist.hs ===================================== @@ -124,11 +124,8 @@ installTo relocatable prefix = do runBuilderWithCmdOptions env (Make bindistFilesDir) ["install"] [] [] -buildBinDistDir :: FilePath -> BindistConfig -> Action () -buildBinDistDir root conf@BindistConfig{..} = do - - verbosity <- getVerbosity - -- We 'need' all binaries and libraries +bindistPackageTargets :: BindistConfig -> Action ([(Package, FilePath)], [(Package, FilePath)]) +bindistPackageTargets conf@BindistConfig{..} = do lib_pkgs <- stagePackages library_stage (lib_targets, _) <- partitionEithers <$> mapM (pkgTarget conf) lib_pkgs @@ -137,6 +134,14 @@ buildBinDistDir root conf@BindistConfig{..} = do let excluded_packages = [ genapply ] bin_pkgs = filter (`notElem` excluded_packages) bin_pkgs_all (_, bin_targets) <- partitionEithers <$> mapM (pkgTarget conf) bin_pkgs + return (lib_targets, bin_targets) + +buildBinDistDir :: FilePath -> BindistConfig -> Action () +buildBinDistDir root conf@BindistConfig{..} = do + + verbosity <- getVerbosity + -- We 'need' all binaries and libraries + (lib_targets, bin_targets) <- bindistPackageTargets conf when (verbosity >= Verbose) $ do let libNames = map (pkgName . fst) lib_targets View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0e0203528dfbad75f2d6ae79404a84a1... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0e0203528dfbad75f2d6ae79404a84a1... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Zubin (@wz1000)