[Git][ghc/ghc][master] 2 commits: RTS: remove target info and fix host info (#24058)

Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: b96e2f77 by Sylvain Henry at 2025-04-18T20:46:33-04:00 RTS: remove target info and fix host info (#24058) The RTS isn't a compiler, hence it doesn't have a target and we remove the reported target info displayed by "+RTS --info". We also fix the host info displayed by "+RTS --info": the host of the RTS is the RTS-building compiler's target, not the compiler's host (wrong when doing cross-compilation). - - - - - 6d9965f4 by Sylvain Henry at 2025-04-18T20:46:33-04:00 RTS: remove build info As per the discussion in !13967, there is no reason to tag the RTS with information about the build platform. - - - - - 5 changed files: - compiler/GHC/Driver/Session.hs - configure.ac - hadrian/src/Settings/Packages.hs - rts/RtsUtils.c - testsuite/ghc-config/ghc-config.hs Changes: ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -236,6 +236,7 @@ import GHC.Prelude import GHC.Platform import GHC.Platform.Ways import GHC.Platform.Profile +import GHC.Platform.ArchOS import GHC.Unit.Types import GHC.Unit.Parser @@ -3455,6 +3456,9 @@ compilerInfo dflags ("Build platform", cBuildPlatformString), ("Host platform", cHostPlatformString), ("Target platform", platformMisc_targetPlatformString $ platformMisc dflags), + ("target os string", stringEncodeOS (platformOS (targetPlatform dflags))), + ("target arch string", stringEncodeArch (platformArch (targetPlatform dflags))), + ("target word size in bits", show (platformWordSizeInBits (targetPlatform dflags))), ("Have interpreter", showBool $ platformMisc_ghcWithInterpreter $ platformMisc dflags), ("Object splitting supported", showBool False), ("Have native code generator", showBool $ platformNcgSupported platform), ===================================== configure.ac ===================================== @@ -265,8 +265,8 @@ dnl we ask the bootstrapping compiler what platform it is for if test "${WithGhc}" != "" then - bootstrap_host=`"${WithGhc}" +RTS --info | grep '^ ,("Host platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'` - bootstrap_target=`"${WithGhc}" +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'` + bootstrap_host=`"${WithGhc}" --info | grep '^ ,("Host platform"' | sed -e 's/.*,"//' -e 's/")//' | tr -d '\r'` + bootstrap_target=`"${WithGhc}" --info | grep '^ ,("Target platform"' | sed -e 's/.*,"//' -e 's/")//' | tr -d '\r'` if test "$bootstrap_host" != "$bootstrap_target" then echo "Bootstrapping GHC is a cross compiler. This probably isn't going to work" ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -286,10 +286,6 @@ ghcInternalArgs = package ghcInternal ? do rtsPackageArgs :: Args rtsPackageArgs = package rts ? do projectVersion <- getSetting ProjectVersion - hostPlatform <- queryHost targetPlatformTriple - hostArch <- queryHost queryArch - hostOs <- queryHost queryOS - hostVendor <- queryHost queryVendor buildPlatform <- queryBuild targetPlatformTriple buildArch <- queryBuild queryArch buildOs <- queryBuild queryOS @@ -371,18 +367,16 @@ rtsPackageArgs = package rts ? do , input "**/RtsUtils.c" ? pure [ "-DProjectVersion=" ++ show projectVersion - , "-DHostPlatform=" ++ show hostPlatform - , "-DHostArch=" ++ show hostArch - , "-DHostOS=" ++ show hostOs - , "-DHostVendor=" ++ show hostVendor + -- the RTS' host is the compiler's target (the target should be + -- per stage ideally...) + , "-DHostPlatform=" ++ show targetPlatform + , "-DHostArch=" ++ show targetArch + , "-DHostOS=" ++ show targetOs + , "-DHostVendor=" ++ show targetVendor , "-DBuildPlatform=" ++ show buildPlatform , "-DBuildArch=" ++ show buildArch , "-DBuildOS=" ++ show buildOs , "-DBuildVendor=" ++ show buildVendor - , "-DTargetPlatform=" ++ show targetPlatform - , "-DTargetArch=" ++ show targetArch - , "-DTargetOS=" ++ show targetOs - , "-DTargetVendor=" ++ show targetVendor , "-DGhcUnregisterised=" ++ show (yesNo ghcUnreg) , "-DTablesNextToCode=" ++ show (yesNo ghcEnableTNC) , "-DRtsWay=\"rts_" ++ show way ++ "\"" ===================================== rts/RtsUtils.c ===================================== @@ -364,18 +364,10 @@ void printRtsInfo(const RtsConfig rts_config) { printf(" [(\"GHC RTS\", \"YES\")\n"); mkRtsInfoPair("GHC version", ProjectVersion); mkRtsInfoPair("RTS way", RtsWay); - mkRtsInfoPair("Build platform", BuildPlatform); - mkRtsInfoPair("Build architecture", BuildArch); - mkRtsInfoPair("Build OS", BuildOS); - mkRtsInfoPair("Build vendor", BuildVendor); mkRtsInfoPair("Host platform", HostPlatform); mkRtsInfoPair("Host architecture", HostArch); mkRtsInfoPair("Host OS", HostOS); mkRtsInfoPair("Host vendor", HostVendor); - mkRtsInfoPair("Target platform", TargetPlatform); - mkRtsInfoPair("Target architecture", TargetArch); - mkRtsInfoPair("Target OS", TargetOS); - mkRtsInfoPair("Target vendor", TargetVendor); mkRtsInfoPair("Word size", TOSTRING(WORD_SIZE_IN_BITS)); // TODO(@Ericson2314) This is a joint property of the RTS and generated // code. The compiler will soon be multi-target so it doesn't make sense to ===================================== testsuite/ghc-config/ghc-config.hs ===================================== @@ -1,6 +1,7 @@ import System.Environment import System.Process import Data.Maybe +import Control.Monad main :: IO () main = do @@ -9,15 +10,25 @@ main = do info <- readProcess ghc ["+RTS", "--info"] "" let fields = read info :: [(String,String)] getGhcFieldOrFail fields "HostOS" "Host OS" - getGhcFieldOrFail fields "WORDSIZE" "Word size" - getGhcFieldOrFail fields "TARGETPLATFORM" "Target platform" - getGhcFieldOrFail fields "TargetOS_CPP" "Target OS" - getGhcFieldOrFail fields "TargetARCH_CPP" "Target architecture" getGhcFieldOrFail fields "RTSWay" "RTS way" + -- support for old GHCs (pre 9.13): infer target platform by querying the rts... + let query_rts = isJust (lookup "Target platform" fields) + when query_rts $ do + getGhcFieldOrFail fields "WORDSIZE" "Word size" + getGhcFieldOrFail fields "TARGETPLATFORM" "Target platform" + getGhcFieldOrFail fields "TargetOS_CPP" "Target OS" + getGhcFieldOrFail fields "TargetARCH_CPP" "Target architecture" + info <- readProcess ghc ["--info"] "" let fields = read info :: [(String,String)] + unless query_rts $ do + getGhcFieldOrFail fields "WORDSIZE" "target word size in bits" + getGhcFieldOrFail fields "TARGETPLATFORM" "target platform string" + getGhcFieldOrFail fields "TargetOS_CPP" "target os string" + getGhcFieldOrFail fields "TargetARCH_CPP" "target arch string" + getGhcFieldOrFail fields "GhcStage" "Stage" getGhcFieldOrFail fields "GhcDebugAssertions" "Debug on" getGhcFieldOrFail fields "GhcWithNativeCodeGen" "Have native code generator" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/386f18548e3c66d04f648a9d34f167a... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/386f18548e3c66d04f648a9d34f167a... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)