[Git][ghc/ghc][wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL] 6 commits: hlint: superfluous parens
Sven Tennie pushed to branch wip/romes/hadrian-cross-stage2-rebase_SVEN_FINAL at Glasgow Haskell Compiler / GHC Commits: 88a9cbc7 by Sven Tennie at 2026-02-26T14:54:43+00:00 hlint: superfluous parens - - - - - 38977c32 by Sven Tennie at 2026-02-26T15:01:12+00:00 Cleanup targetStage - - - - - 5097ecce by Sven Tennie at 2026-02-26T15:03:42+00:00 Delete obsolete TODO - - - - - 1166e656 by Sven Tennie at 2026-02-26T15:10:14+00:00 Disable stripping only for the cross-stage - - - - - ea13d7bf by Sven Tennie at 2026-02-26T15:23:20+00:00 Cleanup inTreeCompilerArgs - - - - - 8dc900bb by Sven Tennie at 2026-02-26T15:23:20+00:00 Cleanup isOptional - - - - - 5 changed files: - hadrian/src/Builder.hs - hadrian/src/Oracles/Setting.hs - hadrian/src/Rules/Test.hs - hadrian/src/Settings/Builders/Cabal.hs - hadrian/src/Settings/Builders/RunTest.hs Changes: ===================================== hadrian/src/Builder.hs ===================================== @@ -415,8 +415,7 @@ isOptional target = \case Alex -> True -- Most ar implemententions no longer need ranlib, but some still do Ranlib {} -> not $ Toolchain.arNeedsRanlib (tgtAr target) - -- TODO: Use stage argument - JsCpp {} -> not $ (archOS_arch . tgtArchOs) target == ArchJavaScript -- ArchWasm32 too? + JsCpp {} -> (archOS_arch . tgtArchOs) target /= ArchJavaScript -- ArchWasm32 too? _ -> False -- | Determine the location of a system 'Builder'. ===================================== hadrian/src/Oracles/Setting.hs ===================================== @@ -7,7 +7,6 @@ module Oracles.Setting ( -- * Helpers ghcCanonVersion, cmdLineLengthLimit, targetSupportsRPaths, topDirectory, libsuf, ghcVersionStage, bashPath, targetStage, crossStage, queryTarget, queryTargetTarget, - isHostStage, -- ** Target platform things anyTargetOs, anyTargetArch, anyHostOs, @@ -233,15 +232,19 @@ libsuf st way -- | Build libraries for this `Stage` targetting this `Target` -- --- For example, we want to build RTS with stage1 for the host target as we --- produce a host executable with stage1 (which cross-compiles to stage2). +-- For example, for cross-compilers we want to build RTS with Stage1 for the +-- host target as we produce a host executable with Stage1 (which +-- cross-compiles to Stage2). +-- +-- For non-cross-compilers we can directly use the final target for Stage1. +-- +-- The algorithm is: +-- Stage0 -> Host +-- Stage1 -> Target, if not cross, Host otherwise +-- >= Stage2 -> Target targetStage :: Stage -> Action Target targetStage Stage0 {} = getHostTarget -targetStage stage | isHostStage stage = do - -- MP: If we are not cross compiling then we should use the target file in order to - -- build things for the host, in particular we want to use the configured values for the - -- target for building the RTS (ie are we using Libffi for adjustors, and the wordsize) - -- TODO: Use "flag CrossCompiling" +targetStage Stage1 = do ht <- getHostTarget tt <- getTargetTarget if targetPlatformTriple ht == targetPlatformTriple tt @@ -249,11 +252,7 @@ targetStage stage | isHostStage stage = do else return ht targetStage _ = getTargetTarget -isHostStage :: Stage -> Bool -isHostStage stage | stage <= Stage1 = True -isHostStage _ = False - -queryTarget :: Stage -> (Target -> a) -> (Expr c b a) +queryTarget :: Stage -> (Target -> a) -> Expr c b a queryTarget s f = expr (f <$> targetStage s) queryTargetTarget :: Stage -> (Target -> a) -> Action a ===================================== hadrian/src/Rules/Test.hs ===================================== @@ -217,7 +217,6 @@ testEnv stg = do top <- topDirectory pythonPath <- builderPath Python - -- MP: TODO wrong, should use the ccPath and ccFlags from the bindist we are testing. ccPath <- queryTargetTarget stg (Toolchain.prgPath . Toolchain.ccProgram . Toolchain.tgtCCompiler) ccFlags <- queryTargetTarget stg (unwords . Toolchain.prgFlags . Toolchain.ccProgram . Toolchain.tgtCCompiler) ghcFlags <- runTestGhcFlags stg ===================================== hadrian/src/Settings/Builders/Cabal.hs ===================================== @@ -90,8 +90,7 @@ commonCabalArgs stage = do -- we might have issues with stripping on Windows, as I can't see a -- consumer of 'stripCmdPath'. -- TODO: See https://github.com/snowleopard/hadrian/issues/549. - -- TODO: MP should check per-stage rather than a global CrossCompiling, but not going to cause bugs - flag CrossCompiling ? pure [ "--disable-executable-stripping" + crossStage stage ? pure [ "--disable-executable-stripping" , "--disable-library-stripping" ] -- We don't want to strip the debug RTS , S.package rts ? pure [ "--disable-executable-stripping" ===================================== hadrian/src/Settings/Builders/RunTest.hs ===================================== @@ -105,50 +105,49 @@ allowHaveLLVM = not . (`elem` ["wasm32", "javascript"]) -- inTreeCompilerArgs :: Stage -> Action TestCompilerArgs inTreeCompilerArgs stg = do - -- TODO: executable and library stage would be clearer cross <- crossStage stg - let ghcStage = succStage stg - pkgCacheStage = if cross then ghcStage else stg + let executableStage = succStage stg + libraryStage = if cross then executableStage else stg (hasDynamicRts, hasThreadedRts) <- do - ways <- interpretInContext (vanillaContext ghcStage rts) getRtsWays + ways <- interpretInContext (vanillaContext executableStage rts) getRtsWays return (dynamic `elem` ways, threaded `elem` ways) - hasDynamic <- (wayUnit Dynamic) . Context.Type.way <$> (programContext stg ghc) - leadingUnderscore <- queryTargetTarget ghcStage tgtSymbolsHaveLeadingUnderscore - withInterpreter <- ghcWithInterpreter ghcStage - unregisterised <- queryTargetTarget ghcStage tgtUnregisterised - tables_next_to_code <- queryTargetTarget ghcStage tgtTablesNextToCode - targetWithSMP <- targetSupportsSMP ghcStage - interpForceDyn <- targetRTSLinkerOnlySupportsSharedLibs ghcStage - - debugAssertions <- ghcDebugAssertions <$> flavour <*> pure ghcStage - debugged <- ghcDebugged <$> flavour <*> pure ghcStage - profiled <- ghcProfiled <$> flavour <*> pure ghcStage + hasDynamic <- wayUnit Dynamic . Context.Type.way <$> programContext stg ghc + leadingUnderscore <- queryTargetTarget executableStage tgtSymbolsHaveLeadingUnderscore + withInterpreter <- ghcWithInterpreter executableStage + unregisterised <- queryTargetTarget executableStage tgtUnregisterised + tables_next_to_code <- queryTargetTarget executableStage tgtTablesNextToCode + targetWithSMP <- targetSupportsSMP executableStage + interpForceDyn <- targetRTSLinkerOnlySupportsSharedLibs executableStage + + debugAssertions <- ghcDebugAssertions <$> flavour <*> pure executableStage + debugged <- ghcDebugged <$> flavour <*> pure executableStage + profiled <- ghcProfiled <$> flavour <*> pure executableStage os <- queryHostTarget queryOS - arch <- queryTargetTarget ghcStage queryArch + arch <- queryTargetTarget executableStage queryArch let codegen_arches = ["x86_64", "i386", "powerpc", "powerpc64", "powerpc64le", "aarch64", "wasm32", "riscv64", "loongarch64"] let withNativeCodeGen | unregisterised = False | arch `elem` codegen_arches = True | otherwise = False - platform <- queryTargetTarget ghcStage targetPlatformTriple - wordsize <- show @Int . (*8) <$> queryTargetTarget ghcStage (wordSize2Bytes . tgtWordSize) + platform <- queryTargetTarget executableStage targetPlatformTriple + wordsize <- show @Int . (*8) <$> queryTargetTarget executableStage (wordSize2Bytes . tgtWordSize) - llc_cmd <- queryTargetTarget ghcStage tgtLlc - llvm_as_cmd <- queryTargetTarget ghcStage tgtLlvmAs + llc_cmd <- queryTargetTarget executableStage tgtLlc + llvm_as_cmd <- queryTargetTarget executableStage tgtLlvmAs let have_llvm = allowHaveLLVM arch && all isJust [llc_cmd, llvm_as_cmd] top <- topDirectory pkgConfCacheFile <- System.FilePath.normalise . (top -/-) - <$> (packageDbPath (PackageDbLoc pkgCacheStage Final) <&> (-/- "package.cache")) + <$> (packageDbPath (PackageDbLoc libraryStage Final) <&> (-/- "package.cache")) libdir <- System.FilePath.normalise . (top -/-) - <$> stageLibPath pkgCacheStage + <$> stageLibPath libraryStage -- For this information, we need to query ghc --info, however, that would -- require building ghc, which we don't want to do here. Therefore, the -- logic from `platformHasRTSLinker` is duplicated here. - let rtsLinker = not $ arch `elem` ["powerpc", "powerpc64", "powerpc64le", "s390x", "loongarch64", "javascript"] + let rtsLinker = arch `notElem` ["powerpc", "powerpc64", "powerpc64le", "s390x", "loongarch64", "javascript"] return TestCompilerArgs{..} View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9644731a56ec97ac84759a080a0168e... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9644731a56ec97ac84759a080a0168e... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Sven Tennie (@supersven)