[Git][ghc/ghc][master] RTS: rely less on Hadrian for flag setting (#25843)

Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a1567efd by Sylvain Henry at 2025-09-01T23:01:35-04:00 RTS: rely less on Hadrian for flag setting (#25843) Hadrian used to pass -Dfoo command-line flags directly to build the rts. We can replace most of these flags with CPP based on cabal flags. It makes building boot libraries with cabal-install simpler (cf #25843). - - - - - 4 changed files: - hadrian/src/Settings/Packages.hs - rts/RtsMessages.c - rts/RtsUtils.c - rts/Trace.c Changes: ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -287,15 +287,6 @@ ghcInternalArgs = package ghcInternal ? do -- | RTS-specific command line arguments. rtsPackageArgs :: Args rtsPackageArgs = package rts ? do - projectVersion <- getSetting ProjectVersion - buildPlatform <- queryBuild targetPlatformTriple - buildArch <- queryBuild queryArch - buildOs <- queryBuild queryOS - buildVendor <- queryBuild queryVendor - targetPlatform <- queryTarget targetPlatformTriple - targetArch <- queryTarget queryArch - targetOs <- queryTarget queryOS - targetVendor <- queryTarget queryVendor ghcUnreg <- queryTarget tgtUnregisterised ghcEnableTNC <- queryTarget tgtTablesNextToCode rtsWays <- getRtsWays @@ -363,25 +354,11 @@ rtsPackageArgs = package rts ? do , inputs ["**/RtsMessages.c", "**/Trace.c"] ? pure - ["-DProjectVersion=" ++ show projectVersion - , "-DRtsWay=\"rts_" ++ show way ++ "\"" + [ "-DRtsWay=\"rts_" ++ show way ++ "\"" ] , input "**/RtsUtils.c" ? pure - [ "-DProjectVersion=" ++ show projectVersion - -- 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 - , "-DGhcUnregisterised=" ++ show (yesNo ghcUnreg) - , "-DTablesNextToCode=" ++ show (yesNo ghcEnableTNC) - , "-DRtsWay=\"rts_" ++ show way ++ "\"" + [ "-DRtsWay=\"rts_" ++ show way ++ "\"" ] -- We're after pure performance here. So make sure fast math and ===================================== rts/RtsMessages.c ===================================== @@ -9,6 +9,7 @@ #include "rts/PosixSource.h" #include "Rts.h" #include "RtsUtils.h" +#include "ghcversion.h" #include "eventlog/EventLog.h" @@ -177,7 +178,7 @@ rtsFatalInternalErrorFn(const char *s, va_list ap) libdwFree(session); #endif fprintf(stderr, "\n"); - fprintf(stderr, " (GHC version %s for %s)\n", ProjectVersion, xstr(HostPlatform_TYPE)); + fprintf(stderr, " (GHC version %s for %s)\n", __GLASGOW_HASKELL_FULL_VERSION__, xstr(HostPlatform_TYPE)); fprintf(stderr, " Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug\n"); fflush(stderr); } ===================================== rts/RtsUtils.c ===================================== @@ -9,6 +9,8 @@ #include "rts/PosixSource.h" #include "Rts.h" #include "RtsAPI.h" +#include "ghcplatform.h" +#include "ghcversion.h" #include "RtsUtils.h" #include "Ticky.h" @@ -369,20 +371,28 @@ void printRtsInfo(const RtsConfig rts_config) { /* The first entry is just a hack to make it easy to get the * commas right */ printf(" [(\"GHC RTS\", \"YES\")\n"); - mkRtsInfoPair("GHC version", ProjectVersion); + mkRtsInfoPair("GHC version", __GLASGOW_HASKELL_FULL_VERSION__); mkRtsInfoPair("RTS way", RtsWay); - mkRtsInfoPair("Host platform", HostPlatform); - mkRtsInfoPair("Host architecture", HostArch); - mkRtsInfoPair("Host OS", HostOS); - mkRtsInfoPair("Host vendor", HostVendor); + mkRtsInfoPair("Host platform", HOST_ARCH "-" HOST_VENDOR "-" HOST_OS); + mkRtsInfoPair("Host architecture", HOST_ARCH); + mkRtsInfoPair("Host OS", HOST_OS); + mkRtsInfoPair("Host vendor", HOST_VENDOR); 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 // say the target is <ABI adj>, unless we are talking about the host // platform of the compiler / ABI used by a compiler plugin. This is *not* // that, so I think a rename is in order to avoid confusion. - mkRtsInfoPair("Compiler unregisterised", GhcUnregisterised); - mkRtsInfoPair("Tables next to code", TablesNextToCode); +#if defined(UnregisterisedCompiler) + mkRtsInfoPair("Compiler unregisterised", "YES"); +#else + mkRtsInfoPair("Compiler unregisterised", "NO"); +#endif +#if defined(TABLES_NEXT_TO_CODE) + mkRtsInfoPair("Tables next to code", "YES"); +#else + mkRtsInfoPair("Tables next to code", "NO"); +#endif mkRtsInfoPair("Flag -with-rtsopts", /* See #15261 */ rts_config.rts_opts != NULL ? rts_config.rts_opts : ""); selectIOManager(); /* resolve the io-manager, accounting for flags */ ===================================== rts/Trace.c ===================================== @@ -8,6 +8,7 @@ // external headers #include "Rts.h" +#include "ghcversion.h" // internal headers #include "Trace.h" @@ -503,7 +504,7 @@ void traceOSProcessInfo_(void) { #endif { char buf[256]; - snprintf(buf, sizeof(buf), "GHC-%s %s", ProjectVersion, RtsWay); + snprintf(buf, sizeof(buf), "GHC-%s %s", __GLASGOW_HASKELL_FULL_VERSION__, RtsWay); postCapsetStrEvent(EVENT_RTS_IDENTIFIER, CAPSET_OSPROCESS_DEFAULT, buf); View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a1567efd3d3e6d5f8cf257366d441fcd... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a1567efd3d3e6d5f8cf257366d441fcd... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)