From c17bb82f1cc66cb819acbfc7727a6b366097a323 Mon Sep 17 00:00:00 2001 From: Rodrigo Mesquita Date: Mon, 8 May 2023 16:19:11 +0100 Subject: Move "target has RTS linker" out of settings We move the "target has RTS linker" information out of configure into a predicate in GHC, and remove this option from the settings file where it is unnecessary -- it's information statically known from the platform. Note that previously we would consider `powerpc`s and `s390x`s other than `powerpc-ibm-aix*` and `s390x-ibm-linux` to have an RTS linker, but the RTS linker supports neither platform. Closes #23361 --- compiler/GHC/Driver/Session.hs | 5 +++-- compiler/GHC/Platform.hs | 18 ++++++++++++++++++ configure.ac | 12 ------------ distrib/configure.ac.in | 3 --- hadrian/bindist/Makefile | 1 - hadrian/bindist/config.mk.in | 1 - hadrian/cfg/system.config.in | 1 - hadrian/src/Oracles/Setting.hs | 2 -- hadrian/src/Rules/Generate.hs | 1 - hadrian/src/Settings/Builders/RunTest.hs | 5 ++++- 10 files changed, 25 insertions(+), 24 deletions(-) diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs index 027b97d226..6a7ba74477 100644 --- a/compiler/GHC/Driver/Session.hs +++ b/compiler/GHC/Driver/Session.hs @@ -4830,8 +4830,9 @@ compilerInfo dflags ("Target platform", platformMisc_targetPlatformString $ platformMisc dflags), ("Have interpreter", showBool $ platformMisc_ghcWithInterpreter $ platformMisc dflags), ("Object splitting supported", showBool False), - ("Have native code generator", showBool $ platformNcgSupported (targetPlatform dflags)), - ("Target default backend", show $ platformDefaultBackend (targetPlatform dflags)), + ("Have native code generator", showBool $ platformNcgSupported platform), + ("target has RTS linker", showBool $ platformHasRTSLinker platform), + ("Target default backend", show $ platformDefaultBackend platform), -- Whether or not we support @-dynamic-too@ ("Support dynamic-too", showBool $ not isWindows), -- Whether or not we support the @-j@ flag with @--make@. diff --git a/compiler/GHC/Platform.hs b/compiler/GHC/Platform.hs index a630e0c1d3..6ea05b30a3 100644 --- a/compiler/GHC/Platform.hs +++ b/compiler/GHC/Platform.hs @@ -29,6 +29,7 @@ module GHC.Platform , platformInIntRange , platformInWordRange , platformCConvNeedsExtension + , platformHasRTSLinker , PlatformMisc(..) , SseVersion (..) , BmiVersion (..) @@ -271,6 +272,23 @@ platformCConvNeedsExtension platform = case platformArch platform of | OSDarwin <- platformOS platform -> True _ -> False +-- | Does this platform have an RTS linker? +platformHasRTSLinker :: Platform -> Bool +-- Note that we've inlined this logic in hadrian's +-- Settings.Builders.RunTest.inTreeCompilerArgs. +-- If you change this, be sure to change it too +platformHasRTSLinker p = case archOS_arch (platformArchOS p) of + ArchPPC -> False -- powerpc + ArchPPC_64 ELF_V1 -> False -- powerpc64 + ArchPPC_64 ELF_V2 -> False -- powerpc64le + ArchS390X -> False + ArchRISCV64 -> False + ArchLoongArch64 -> False + ArchJavaScript -> False + ArchWasm32 -> False + _ -> True + + -------------------------------------------------- -- Instruction sets diff --git a/configure.ac b/configure.ac index 49b1e9683c..899a6e65a8 100644 --- a/configure.ac +++ b/configure.ac @@ -330,18 +330,6 @@ if test x"$TablesNextToCode" = xYES; then fi AC_SUBST(TablesNextToCode) -dnl ** Does target have runtime linker support? -dnl -------------------------------------------------------------- -case "$target" in - powerpc64-*|powerpc64le-*|powerpc-ibm-aix*|s390x-ibm-linux|riscv64-*|wasm*|javascript-*|loongarch64-*) - TargetHasRTSLinker=NO - ;; - *) - TargetHasRTSLinker=YES - ;; -esac -AC_SUBST(TargetHasRTSLinker) - # Requires FPTOOLS_SET_PLATFORMS_VARS to be run first. FP_FIND_ROOT diff --git a/distrib/configure.ac.in b/distrib/configure.ac.in index 7077062c25..ce75510b8a 100644 --- a/distrib/configure.ac.in +++ b/distrib/configure.ac.in @@ -20,9 +20,6 @@ bootstrap_target=@TargetPlatform@ bootstrap_llvm_target=@LlvmTarget@ -TargetHasRTSLinker=@TargetHasRTSLinker@ -AC_SUBST(TargetHasRTSLinker) - TargetHasLibm=@TargetHasLibm@ AC_SUBST(TargetHasLibm) diff --git a/hadrian/bindist/Makefile b/hadrian/bindist/Makefile index 3f18720253..37e7504969 100644 --- a/hadrian/bindist/Makefile +++ b/hadrian/bindist/Makefile @@ -116,7 +116,6 @@ lib/settings : config.mk @echo ',("target has GNU nonexec stack", "$(TargetHasGnuNonexecStack)")' >> $@ @echo ',("target has .ident directive", "$(TargetHasIdentDirective)")' >> $@ @echo ',("target has subsections via symbols", "$(TargetHasSubsectionsViaSymbols)")' >> $@ - @echo ',("target has RTS linker", "$(TargetHasRTSLinker)")' >> $@ @echo ',("target has libm", "$(TargetHasLibm)")' >> $@ @echo ',("Unregisterised", "$(GhcUnregisterised)")' >> $@ @echo ',("LLVM target", "$(LLVMTarget_CPP)")' >> $@ diff --git a/hadrian/bindist/config.mk.in b/hadrian/bindist/config.mk.in index a134a00bd7..c98e25e58e 100644 --- a/hadrian/bindist/config.mk.in +++ b/hadrian/bindist/config.mk.in @@ -253,7 +253,6 @@ TargetWordBigEndian = @TargetWordBigEndian@ TargetHasGnuNonexecStack = @TargetHasGnuNonexecStack@ TargetHasIdentDirective = @TargetHasIdentDirective@ TargetHasSubsectionsViaSymbols = @TargetHasSubsectionsViaSymbols@ -TargetHasRTSLinker = @TargetHasRTSLinker@ TargetHasLibm = @TargetHasLibm@ TablesNextToCode = @TablesNextToCode@ diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in index 57c57aa057..17465d2fb4 100644 --- a/hadrian/cfg/system.config.in +++ b/hadrian/cfg/system.config.in @@ -173,7 +173,6 @@ target-word-big-endian = @TargetWordBigEndian@ target-has-gnu-nonexec-stack = @TargetHasGnuNonexecStack@ target-has-ident-directive = @TargetHasIdentDirective@ target-has-subsections-via-symbols = @TargetHasSubsectionsViaSymbols@ -target-has-rts-linker = @TargetHasRTSLinker@ target-has-libm = @TargetHasLibm@ target-arm-version = @ARM_ISA@ diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs index bf49bd1fe0..0ff3174673 100644 --- a/hadrian/src/Oracles/Setting.hs +++ b/hadrian/src/Oracles/Setting.hs @@ -79,7 +79,6 @@ data Setting = BuildArch | TargetOsHaskell | TargetArmVersion | TargetWordSize - | TargetHasRtsLinker | BourneShell -- TODO: Reduce the variety of similar flags (e.g. CPP and non-CPP versions). @@ -181,7 +180,6 @@ setting key = lookupSystemConfig $ case key of TargetArchHaskell -> "target-arch-haskell" TargetOsHaskell -> "target-os-haskell" TargetWordSize -> "target-word-size" - TargetHasRtsLinker -> "target-has-rts-linker" BourneShell -> "bourne-shell" bootIsStage0 :: Stage -> Stage diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs index 6aa9f19b47..32a35e9048 100644 --- a/hadrian/src/Rules/Generate.hs +++ b/hadrian/src/Rules/Generate.hs @@ -448,7 +448,6 @@ generateSettings = do , ("target has GNU nonexec stack", expr $ lookupSystemConfig "target-has-gnu-nonexec-stack") , ("target has .ident directive", expr $ lookupSystemConfig "target-has-ident-directive") , ("target has subsections via symbols", expr $ lookupSystemConfig "target-has-subsections-via-symbols") - , ("target has RTS linker", expr $ lookupSystemConfig "target-has-rts-linker") , ("target has libm", expr $ lookupSystemConfig "target-has-libm") , ("Unregisterised", expr $ yesNo <$> flag GhcUnregisterised) , ("LLVM target", getSetting LlvmTarget) diff --git a/hadrian/src/Settings/Builders/RunTest.hs b/hadrian/src/Settings/Builders/RunTest.hs index 5e1e16d5aa..b526294f40 100644 --- a/hadrian/src/Settings/Builders/RunTest.hs +++ b/hadrian/src/Settings/Builders/RunTest.hs @@ -134,7 +134,10 @@ inTreeCompilerArgs stg = do libdir <- System.FilePath.normalise . (top -/-) <$> stageLibPath stg - rtsLinker <- (== "YES") <$> setting TargetHasRtsLinker + -- 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", "riscv64", "loongarch64", "javascript", "wasm32"] return TestCompilerArgs{..} -- cgit v1.2.1