Sven Tennie pushed to branch wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL at Glasgow Haskell Compiler / GHC Commits: e37b92d3 by Sven Tennie at 2026-06-06T14:10:43+00:00 hadrian: Fix ghc-in-ghci flavour: use targetSupportsSharedLibs not targetSupportsThreadedRts Dynamic way requires shared lib support, not threaded RTS support. - - - - - 70d2c50d by Sven Tennie at 2026-06-06T14:12:13+00:00 hadrian: Revert superfluous whitespace change in Validate.hs - - - - - 077791e0 by Sven Tennie at 2026-06-06T14:16:22+00:00 hadrian: Restore original way order in defaultLibraryWays - - - - - dac4e3cc by Sven Tennie at 2026-06-06T14:19:30+00:00 hadrian: Restore x86 variable name in rtsPackageArgs - - - - - 1932d641 by Sven Tennie at 2026-06-06T14:29:09+00:00 hadrian: Restore original import order and list order to reduce diff noise - - - - - f53c009a by Sven Tennie at 2026-06-06T14:29:46+00:00 hadrian: Remove spurious blank lines to reduce diff noise - - - - - de86be23 by Sven Tennie at 2026-06-06T14:36:39+00:00 hadrian: Eliminate duplicate parsePath call in Compile.hs - - - - - 210ac3ff by Sven Tennie at 2026-06-06T15:12:17+00:00 hadrian: use staged isOsxTarget and drop stale cross exception in splitSectionsArgs Replace manual `getStage` + `isOsxTarget stage` with `staged isOsxTarget`. Drop `cross || notSt0` in favour of plain `notSt0`: the cross exception was valid when Stage0 cross-compiled binaries shipped to the target, but Stage0 packages always run on the host, so the exception no longer applies. - - - - - 78502733 by Sven Tennie at 2026-06-06T15:15:43+00:00 hadrian: drop stale cross exception in ghcWithInterpreter The `stage >= Stage1 || is_cross` condition enabled GHCi for Stage0 when cross compiling. This was valid when Stage0 cross-compiled binaries shipped to the target, but Stage0 packages always run on the host and are never shipped, so the exception no longer applies. Drop `is_cross` and simplify to `stage >= Stage1`. - - - - - 10 changed files: - hadrian/src/Expression.hs - hadrian/src/Rules/Compile.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Settings/Builders/RunTest.hs - hadrian/src/Settings/Builders/SplitSections.hs - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Flavours/GhcInGhci.hs - hadrian/src/Settings/Flavours/Validate.hs - hadrian/src/Settings/Packages.hs - hadrian/src/Settings/Program.hs Changes: ===================================== hadrian/src/Expression.hs ===================================== @@ -52,7 +52,6 @@ package p = (p ==) <$> getPackage packageOneOf :: [Package] -> Predicate packageOneOf ps = (`elem` ps) <$> getPackage - -- | This type class allows the user to construct both precise builder -- predicates, such as @builder (Ghc CompileHs Stage1)@, as well as predicates -- covering a set of similar builders. For example, @builder (Ghc CompileHs)@ ===================================== hadrian/src/Rules/Compile.hs ===================================== @@ -62,12 +62,11 @@ compilePackage rs = do forM_ wayPats $ \wayPat -> ( root -/- ("**/build/**/*." ++ wayPat ++ "dyn_o") :& root -/- ("**/build/**/*." ++ wayPat ++ "dyn_hi") :& Nil ) &%> \ ( dyn_o :& _dyn_hi :& _ ) -> do - (BuildPath _root stage _path _o) + b@(BuildPath _root stage _path _o) <- parsePath (parseBuildObject root) "<object file path parser>" dyn_o p <- targetSupportsSharedLibs stage if p then do - b <- parsePath (parseBuildObject root) "<object file path parser>" dyn_o let ctx = objectContext b way = removeWayUnit Dynamic $ C.way ctx -- We `need` ".o/.hi" because GHC is called with `-dynamic-too` ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -5,6 +5,7 @@ module Rules.Generate ( ) where import Development.Shake.FilePath +import qualified Data.Set as Set import Base import qualified Context import Expression @@ -12,7 +13,6 @@ import Hadrian.Oracles.TextFile (lookupStageBuildConfig) import Oracles.Flag hiding (arSupportsAtFile, arSupportsDashL) import Oracles.ModuleFiles import Oracles.Setting -import Settings.Program (ghcWithInterpreter) import Hadrian.Haskell.Cabal.Type (PackageData(version)) import Hadrian.Haskell.Cabal import Hadrian.Oracles.Cabal (readPackageData) @@ -23,7 +23,7 @@ import Utilities import GHC.Toolchain as Toolchain hiding (HsCpp(HsCpp)) import GHC.Platform.ArchOS -import qualified Data.Set as Set +import Settings.Program (ghcWithInterpreter) import UserSettings (finalStage) -- | Track this file to rebuild generated files whenever it changes. ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -343,7 +343,6 @@ getTestArgs = do hp2ps_path <- expr $ getTestExePath testGhc hp2ps hpc_path <- expr $ getTestExePath testGhc hpc - -- the testsuite driver will itself tell us if we need to generate the docs target -- So we always pass the haddock path if the hadrian configuration allows us to build -- docs ===================================== hadrian/src/Settings/Builders/SplitSections.hs ===================================== @@ -12,19 +12,17 @@ import Flavour.Type splitSectionsArgs :: Args splitSectionsArgs = do pkg <- getPackage - stage <- getStage - osx <- expr (isOsxTarget stage) - cross <- expr $ flag CrossCompiling + osx <- staged isOsxTarget notSt0 <- notStage0 flav <- expr flavour if ( ghcSplitSections flav -- Flavour enables split-sections && not osx -- OS X doesn't support split sections - && (cross || notSt0) + && notSt0 -- Disable for stage 0 because we aren't going to ship -- the resulting binaries and consequently there is no - -- reason to minimize size. Unless cross compiling. + -- reason to minimize size. && (pkg /= ghc) -- Disable section splitting for the GHC library. -- It takes too long and there is little benefit. ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -71,9 +71,9 @@ stageBootPackages = return , hsc2hs , compareSizes , deriveConstants + , genapply , genprimopcode , unlit - , genapply ] -- | Packages built in 'Stage0' by default. You can change this in "UserSettings". @@ -220,7 +220,7 @@ defaultLibraryWays = do mconcat [ pure [vanilla] , notStage0 ? pure [profiling] - , notStage0 ? targetSupportsSharedLibs stage ? pure [profilingDynamic, dynamic] + , notStage0 ? targetSupportsSharedLibs stage ? pure [dynamic, profilingDynamic] ] -- | Default build ways for the RTS. ===================================== hadrian/src/Settings/Flavours/GhcInGhci.hs ===================================== @@ -15,7 +15,7 @@ ghcInGhciFlavour = disableProfiledLibs $ defaultFlavour Set.fromList <$> mconcat [ pure [vanilla] - , staged targetSupportsThreadedRts ? pure [dynamic] + , staged targetSupportsSharedLibs ? pure [dynamic] ] } ===================================== hadrian/src/Settings/Flavours/Validate.hs ===================================== @@ -1,6 +1,7 @@ module Settings.Flavours.Validate (validateFlavour, slowValidateFlavour, quickValidateFlavour) where + import Expression import Flavour import {-# SOURCE #-} Settings.Default ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -1,6 +1,5 @@ module Settings.Packages (packageArgs) where -import Data.Version.Extra import Expression import Flavour import Oracles.Setting @@ -8,11 +7,12 @@ import Oracles.Flag import Packages import Settings import Settings.Builders.Common (wayCcArgs) -import Settings.Program (ghcWithInterpreter) import qualified GHC.Toolchain.Library as Lib import GHC.Toolchain.Target import GHC.Platform.ArchOS +import Data.Version.Extra +import Settings.Program (ghcWithInterpreter) -- | Package-specific command-line arguments. packageArgs :: Args @@ -312,8 +312,7 @@ rtsPackageArgs = package rts ? do predStage stage else stage - -- Figure out if the host (the arch where GHC is running on) is x86 - x86Host <- queryTarget stage' (\ tgt -> archOS_arch (tgtArchOs tgt) `elem` [ ArchX86, ArchX86_64 ]) + x86 <- queryTarget stage' (\ tgt -> archOS_arch (tgtArchOs tgt) `elem` [ ArchX86, ArchX86_64 ]) -- Arguments passed to GHC when compiling C and .cmm sources. let ghcArgs = mconcat @@ -330,11 +329,11 @@ rtsPackageArgs = package rts ? do -- -- In particular, we **do not** pass -mavx when compiling -- AutoApply_V16.cmm, as that would lock out targets with SSE2 but not AVX. - , inputs ["**/AutoApply_V32.cmm"] ? pure [ "-mavx2" | x86Host ] - , inputs ["**/AutoApply_V64.cmm"] ? pure [ "-mavx512f" | x86Host ] + , inputs ["**/AutoApply_V32.cmm"] ? pure [ "-mavx2" | x86 ] + , inputs ["**/AutoApply_V64.cmm"] ? pure [ "-mavx512f" | x86 ] - , inputs ["**/Jumps_V32.cmm"] ? pure [ "-mavx2" | x86Host ] - , inputs ["**/Jumps_V64.cmm"] ? pure [ "-mavx512f" | x86Host ] + , inputs ["**/Jumps_V32.cmm"] ? pure [ "-mavx2" | x86 ] + , inputs ["**/Jumps_V64.cmm"] ? pure [ "-mavx512f" | x86 ] ] let cArgs = mconcat @@ -379,11 +378,11 @@ rtsPackageArgs = package rts ? do , inputs ["**/Evac.c", "**/Evac_thr.c"] ? arg "-funroll-loops" -- See Note [AutoApply.cmm for vectors] in genapply/Main.hs - , inputs ["**/AutoApply_V32.c"] ? pure [ "-mavx2" | x86Host ] - , inputs ["**/AutoApply_V64.c"] ? pure [ "-mavx512f" | x86Host ] + , inputs ["**/AutoApply_V32.c"] ? pure [ "-mavx2" | x86 ] + , inputs ["**/AutoApply_V64.c"] ? pure [ "-mavx512f" | x86 ] - , inputs ["**/Jumps_V32.c"] ? pure [ "-mavx2" | x86Host ] - , inputs ["**/Jumps_V64.c"] ? pure [ "-mavx512f" | x86Host ] + , inputs ["**/Jumps_V32.c"] ? pure [ "-mavx2" | x86 ] + , inputs ["**/Jumps_V64.c"] ? pure [ "-mavx512f" | x86 ] -- emits warnings about call-clobbered registers on x86_64 , inputs [ "**/StgCRun.c" ===================================== hadrian/src/Settings/Program.hs ===================================== @@ -6,7 +6,6 @@ module Settings.Program import Base import Context import Oracles.Flavour -import Oracles.Flag import Packages import GHC.Platform.ArchOS @@ -31,16 +30,11 @@ programContext stage pkg = do notStage0 (Stage0 {}) = False notStage0 _ = True --- | When cross compiling, enable for stage0 to get ghci --- support. But when not cross compiling, disable for --- stage0, otherwise we introduce extra dependencies --- like haskeline etc, and mixing stageBoot/stage0 libs --- can cause extra trouble (e.g. #25406) --- --- Also checks whether the target supports GHCi. +-- | Check whether the target supports GHCi. +-- Disable for stage 0: it would introduce extra dependencies like haskeline, +-- and mixing stageBoot/stage0 libs can cause trouble (e.g. #25406). ghcWithInterpreter :: Stage -> Action Bool ghcWithInterpreter stage = do - is_cross <- flag CrossCompiling goodOs <- anyTargetOs stage [ OSMinGW32, OSLinux, OSSolaris2 , OSFreeBSD, OSDragonFly, OSNetBSD, OSOpenBSD , OSDarwin, OSKFreeBSD @@ -58,6 +52,4 @@ ghcWithInterpreter stage = do -- fall back on dynamic linking: dynamicGhcProgs <- askDynGhcPrograms stage - -- Maybe this should just be false for cross compilers. But for now - -- I've kept the old behaviour where it will say yes. (See #25939) - return $ ((goodOs && goodArch) || dynamicGhcProgs) && (stage >= Stage1 || is_cross) + return $ ((goodOs && goodArch) || dynamicGhcProgs) && stage >= Stage1 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7c66c03566d20d8d2896369f6dc5074... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7c66c03566d20d8d2896369f6dc5074... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Sven Tennie (@supersven)