[Git][ghc/ghc][master] Move "target has RTS linker" out of settings

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu May 11 08:12:29 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
c17bb82f by Rodrigo Mesquita at 2023-05-11T04:12:07-04:00
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

- - - - -


10 changed files:

- compiler/GHC/Driver/Session.hs
- compiler/GHC/Platform.hs
- configure.ac
- distrib/configure.ac.in
- hadrian/bindist/Makefile
- hadrian/bindist/config.mk.in
- hadrian/cfg/system.config.in
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Rules/Generate.hs
- hadrian/src/Settings/Builders/RunTest.hs


Changes:

=====================================
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 at .


=====================================
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


=====================================
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
 


=====================================
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)
 


=====================================
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)")' >> $@


=====================================
hadrian/bindist/config.mk.in
=====================================
@@ -253,7 +253,6 @@ TargetWordBigEndian = @TargetWordBigEndian@
 TargetHasGnuNonexecStack = @TargetHasGnuNonexecStack@
 TargetHasIdentDirective = @TargetHasIdentDirective@
 TargetHasSubsectionsViaSymbols = @TargetHasSubsectionsViaSymbols@
-TargetHasRTSLinker = @TargetHasRTSLinker@
 TargetHasLibm = @TargetHasLibm@
 TablesNextToCode = @TablesNextToCode@
 


=====================================
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@
 


=====================================
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


=====================================
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)


=====================================
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{..}
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c17bb82f1cc66cb819acbfc7727a6b366097a323

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c17bb82f1cc66cb819acbfc7727a6b366097a323
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230511/ef4a76d0/attachment-0001.html>


More information about the ghc-commits mailing list