Sven Tennie pushed to branch wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL at Glasgow Haskell Compiler / GHC Commits: bd48451c by Sven Tennie at 2026-02-18T17:20:19+01:00 Clarify the interpreter story - - - - - 3 changed files: - hadrian/src/Rules/Generate.hs - hadrian/src/Settings/Packages.hs - hadrian/src/Settings/Program.hs Changes: ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -491,7 +491,7 @@ generateSettings settingsFile = do settings <- traverse sequence $ [ ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit, Context.stage = predStage stage }))) - , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter (predStage stage)) + , ("Use interpreter", expr $ yesNo <$> ghcWithInterpreter stage) -- Hard-coded as Cabal queries these to determine way support and we -- need to always advertise all ways when bootstrapping. -- The settings file is generated at install time when installing a bindist. ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -8,7 +8,7 @@ import Oracles.Flag import Packages import Settings import Settings.Builders.Common (wayCcArgs) -import Settings.Program (ghcWithInterpreter) +import Settings.Program (ghcWithInterpreter, ghcWithInternalInterpreter) import qualified GHC.Toolchain.Library as Lib import GHC.Toolchain.Target @@ -27,9 +27,12 @@ packageArgs = do cross = flag CrossCompiling haveCurses = any (/= "") <$> traverse (`buildSetting` stage) [ CursesIncludeDir, CursesLibDir ] + -- Check if the bootstrap compiler has the same version as the one we + -- are building. This is used to build cross-compilers + bootCross = (==) <$> ghcVersionStage (stage0InTree) <*> ghcVersionStage Stage1 + compilerStageOption f = buildingCompilerStage' . f =<< expr flavour - isCrossStage <- staged crossStage cursesIncludeDir <- staged (buildSetting CursesIncludeDir) cursesLibraryDir <- staged (buildSetting CursesLibDir) ffiIncludeDir <- staged (buildSetting FfiIncludeDir) @@ -88,7 +91,7 @@ packageArgs = do -- on the host and must rely on external interpreter to load -- target code, otherwise enable for stage2 since that runs on -- the target and can use target's own ghci object linker - [ expr (ghcWithInterpreter stage) `cabalFlag` "internal-interpreter" + [ ghcWithInterpreter stage `cabalFlag` "internal-interpreter" , orM [ notM cross, haveCurses ] `cabalFlag` "terminfo" , arg "-build-tool-depends" , staged (buildFlag UseLibzstd) `cabalFlag` "with-libzstd" @@ -110,8 +113,8 @@ packageArgs = do , compilerStageOption ghcDebugAssertions ? arg "-DDEBUG" ] , builder (Cabal Flags) ? mconcat - [ expr (ghcWithInterpreter stage) `cabalFlag` "interpreter" - , andM [expr (ghcWithInterpreter stage), notM (pure isCrossStage)] `cabalFlag` "internal-interpreter" + [ ghcWithInterpreter (succStage stage) `cabalFlag` "interpreter" + , ghcWithInternalInterpreter (succStage stage) `cabalFlag` "internal-interpreter" , ifM stage0 -- We build a threaded stage 1 if the bootstrapping compiler -- supports it. @@ -162,10 +165,11 @@ packageArgs = do -- builder (Cabal Setup) ? cabalExtraDirs ffiIncludeDir ffiLibraryDir , builder (Cabal Flags) ? mconcat - [ stage0 `cabalFlag` "bootstrap", - andM [expr (ghcWithInterpreter stage), notM (pure isCrossStage)] `cabalFlag` "internal-interpreter" + [ ifM stage0 + (andM [cross, bootCross] `cabalFlag` "internal-interpreter") + (arg "internal-interpreter") + , stage0 `cabalFlag` "bootstrap" ] - ] , package unix ? builder (Cabal Flags) ? arg "+os-string" ===================================== hadrian/src/Settings/Program.hs ===================================== @@ -1,7 +1,9 @@ module Settings.Program ( programContext , ghcWithInterpreter - ) where + , archSupportsInternalInterpreter + , ghcWithInternalInterpreter +) where import Base import Context @@ -9,7 +11,7 @@ import Oracles.Flavour import Packages import GHC.Platform.ArchOS -import Settings.Builders.Common (anyTargetOs, anyTargetArch, isArmTarget) +import Settings.Builders.Common (anyTargetOs, anyTargetArch, isArmTarget, crossStage) -- TODO: there is duplication and inconsistency between this and -- Rules.Program.getProgramContexts. There should only be one way to @@ -39,6 +41,18 @@ programContext stage pkg = do -- Also checks whether the target supports GHCi. ghcWithInterpreter :: Stage -> Action Bool ghcWithInterpreter stage = do + hasInternalInterpreter <- ghcWithInternalInterpreter stage + isCross <- crossStage stage + return $ (hasInternalInterpreter || isCross) && (stage >= Stage1) + +ghcWithInternalInterpreter :: Stage -> Action Bool +ghcWithInternalInterpreter stage = do + hasInternalInterpreter <- archSupportsInternalInterpreter stage + isCross <- crossStage stage + return $ hasInternalInterpreter && not isCross && (stage >= Stage1) + +archSupportsInternalInterpreter :: Stage -> Action Bool +archSupportsInternalInterpreter stage = do goodOs <- anyTargetOs stage [ OSMinGW32, OSLinux, OSSolaris2 , OSFreeBSD, OSDragonFly, OSNetBSD, OSOpenBSD , OSDarwin, OSKFreeBSD @@ -56,4 +70,4 @@ ghcWithInterpreter stage = do -- fall back on dynamic linking: dynamicGhcProgs <- askDynGhcPrograms stage - return $ ((goodOs && goodArch) || dynamicGhcProgs) && (stage >= Stage2) + return $ (goodOs && goodArch) || dynamicGhcProgs View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bd48451cb3d037509298a0c78d21bb91... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bd48451cb3d037509298a0c78d21bb91... You're receiving this email because of your account on gitlab.haskell.org.