
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0fb24420 by Rodrigo Mesquita at 2025-07-07T20:43:49-04:00 hadrian: Fallback logic for internal interpreter When determining whether to build the internal interpreter, the `make` build system had a fallback case for platforms not in the list of explicitly-supported operating systems and architectures. This fallback says we should try to build the internal interpreter if building dynamic GHC programs (if the architecture is unknown). Fixes #24098 - - - - - 5 changed files: - hadrian/src/Oracles/Flag.hs - hadrian/src/Rules/Generate.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Packages.hs - hadrian/src/Settings/Program.hs Changes: ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -7,7 +7,6 @@ module Oracles.Flag ( targetRTSLinkerOnlySupportsSharedLibs, targetSupportsThreadedRts, targetSupportsSMP, - ghcWithInterpreter, useLibffiForAdjustors, arSupportsDashL, arSupportsAtFile @@ -146,31 +145,5 @@ targetSupportsSMP = do | goodArch -> return True | otherwise -> return False - --- | 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. -ghcWithInterpreter :: Stage -> Action Bool -ghcWithInterpreter stage = do - is_cross <- flag CrossCompiling - goodOs <- anyTargetOs [ OSMinGW32, OSLinux, OSSolaris2 -- TODO "cygwin32"?, - , OSFreeBSD, OSDragonFly, OSNetBSD, OSOpenBSD - , OSDarwin, OSKFreeBSD - , OSWasi ] - goodArch <- (||) <$> - anyTargetArch [ ArchX86, ArchX86_64, ArchPPC - , ArchAArch64, ArchS390X - , ArchPPC_64 ELF_V1, ArchPPC_64 ELF_V2 - , ArchRISCV64, ArchLoongArch64 - , ArchWasm32 ] - <*> isArmTarget - -- 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 && (stage >= Stage1 || is_cross) - useLibffiForAdjustors :: Action Bool useLibffiForAdjustors = queryTargetTarget tgtUseLibffiForAdjustors ===================================== hadrian/src/Rules/Generate.hs ===================================== @@ -26,6 +26,7 @@ import Utilities import GHC.Toolchain as Toolchain hiding (HsCpp(HsCpp)) import GHC.Toolchain.Program import GHC.Platform.ArchOS +import Settings.Program (ghcWithInterpreter) -- | Track this file to rebuild generated files whenever it changes. trackGenerateHs :: Expr () ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -11,7 +11,7 @@ import Settings.Builders.Common import qualified Settings.Builders.Common as S import Control.Exception (assert) import qualified Data.Set as Set -import Settings.Program (programContext) +import Settings.Program (programContext, ghcWithInterpreter) import GHC.Toolchain (ccLinkProgram, tgtCCompilerLink) import GHC.Toolchain.Program (prgFlags) ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -11,6 +11,7 @@ import Settings.Builders.Common (wayCcArgs) import GHC.Toolchain.Target import GHC.Platform.ArchOS import Data.Version.Extra +import Settings.Program (ghcWithInterpreter) -- | Package-specific command-line arguments. packageArgs :: Args ===================================== hadrian/src/Settings/Program.hs ===================================== @@ -1,12 +1,17 @@ module Settings.Program ( programContext + , ghcWithInterpreter ) where import Base import Context import Oracles.Flavour +import Oracles.Flag import Packages +import GHC.Platform.ArchOS +import Settings.Builders.Common (anyTargetOs, anyTargetArch, isArmTarget) + -- TODO: there is duplication and inconsistency between this and -- Rules.Program.getProgramContexts. There should only be one way to -- get a context/contexts for a given stage and package. @@ -24,3 +29,33 @@ 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. +ghcWithInterpreter :: Stage -> Action Bool +ghcWithInterpreter stage = do + is_cross <- flag CrossCompiling + goodOs <- anyTargetOs [ OSMinGW32, OSLinux, OSSolaris2 -- TODO "cygwin32"?, + , OSFreeBSD, OSDragonFly, OSNetBSD, OSOpenBSD + , OSDarwin, OSKFreeBSD + , OSWasi ] + goodArch <- (||) <$> + anyTargetArch [ ArchX86, ArchX86_64, ArchPPC + , ArchAArch64, ArchS390X + , ArchPPC_64 ELF_V1, ArchPPC_64 ELF_V2 + , ArchRISCV64, ArchLoongArch64 + , ArchWasm32 ] + <*> isArmTarget + -- The explicit support list is essentially a list of platforms for which + -- the RTS linker has support. If the RTS linker is not supported then we + -- fall back on dynamic linking: + dynamicGhcProgs <- askDynGhcPrograms + + -- 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) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fb24420f4129aaf4e41114b6615d43d... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0fb24420f4129aaf4e41114b6615d43d... You're receiving this email because of your account on gitlab.haskell.org.