[Git][ghc/ghc][wip/req_smp] test the RTS in config/ghc not hadrian

doyougnu (@doyougnu) gitlab at gitlab.haskell.org
Thu Dec 22 19:57:12 UTC 2022



doyougnu pushed to branch wip/req_smp at Glasgow Haskell Compiler / GHC


Commits:
c9401f21 by doyougnu at 2022-12-22T14:56:36-05:00
test the RTS in config/ghc not hadrian

- - - - -


4 changed files:

- hadrian/src/Oracles/Flag.hs
- hadrian/src/Settings/Builders/RunTest.hs
- testsuite/config/ghc
- testsuite/driver/testglobals.py


Changes:

=====================================
hadrian/src/Oracles/Flag.hs
=====================================
@@ -4,7 +4,6 @@ module Oracles.Flag (
     Flag (..), flag, getFlag,
     platformSupportsSharedLibs,
     platformSupportsGhciObjects,
-    bootstrapperSupportsSMP,
     targetSupportsThreadedRts,
     targetSupportsSMP,
     useLibffiForAdjustors,
@@ -106,10 +105,6 @@ targetSupportsThreadedRts = do
     bad_arch <- anyTargetArch [ "wasm32", "js" ]
     return $ not bad_arch
 
-bootstrapperSupportsSMP :: Action Bool
-bootstrapperSupportsSMP = flag BootstrapThreadedRts
-
-
 -- | Does the target support the -N RTS flag?
 targetSupportsSMP :: Action Bool
 targetSupportsSMP = do


=====================================
hadrian/src/Settings/Builders/RunTest.hs
=====================================
@@ -68,8 +68,7 @@ data TestCompilerArgs = TestCompilerArgs{
  ,   withInterpreter   :: Bool
  ,   unregisterised    :: Bool
  ,   tables_next_to_code :: Bool
- ,   targetWithSMP       :: Bool
- ,   bootstrapperWithSMP :: Bool
+ ,   targetWithSMP       :: Bool  -- does the target support SMP
  ,   debugAssertions     :: Bool
       -- ^ Whether the compiler has debug assertions enabled,
       -- corresponding to the -DDEBUG option.
@@ -102,7 +101,6 @@ inTreeCompilerArgs stg = do
     unregisterised      <- flag GhcUnregisterised
     tables_next_to_code <- flag TablesNextToCode
     targetWithSMP       <- targetSupportsSMP
-    bootstrapperWithSMP <- bootstrapperSupportsSMP
     debugAssertions     <- ($ stg) . ghcDebugAssertions <$> flavour
     profiled            <- ghcProfiled        <$> flavour <*> pure stg
 
@@ -148,7 +146,6 @@ outOfTreeCompilerArgs = do
     withInterpreter     <- getBooleanSetting TestGhcWithInterpreter
     unregisterised      <- getBooleanSetting TestGhcUnregisterised
     tables_next_to_code <- getBooleanSetting TestGhcUnregisterised
-    bootstrapperWithSMP <- getBooleanSetting TestGhcWithSMP
     targetWithSMP       <- getBooleanSetting TestGhcWithSMP
     debugAssertions     <- getBooleanSetting TestGhcDebugged
 
@@ -266,9 +263,6 @@ runTestBuilderArgs = builder Testsuite ? do
             , arg "-e", arg $ asBool "ghc_with_dynamic_rts="  (hasDynamicRts)
             , arg "-e", arg $ asBool "ghc_with_threaded_rts=" (hasThreadedRts)
             , arg "-e", arg $ asBool "config.have_fast_bignum=" (bignumBackend /= "native" && not bignumCheck)
-            , arg "-e", arg $ asBool "ghc_with_smp="    (if stageNumber (C.stage ctx) == 1 || isCross
-                                                         then targetWithSMP
-                                                         else bootstrapperWithSMP)
             , arg "-e", arg $ asBool "target_with_smp=" targetWithSMP
 
             , arg "-e", arg $ "config.ghc_dynamic=" ++ show hasDynamic


=====================================
testsuite/config/ghc
=====================================
@@ -43,12 +43,11 @@ if ghc_with_native_codegen:
 if config.have_interp:
     config.run_ways.append('ghci')
 
-if ghc_with_smp:
-    config.ghc_has_smp = True
-
+# we read the 'Support SMP' setting from the ghcconfig file. This dictates
+# whether the target supports smp
 if ghc_with_threaded_rts:
     config.run_ways.append('threaded1')
-    if target_with_smp:
+    if ghc_with_smp:
         config.target_have_smp = True
         config.run_ways.append('threaded2')
         if config.speed == 0:
@@ -213,11 +212,11 @@ def get_compiler_info():
     # See Note [Replacing backward slashes in config.libdir].
     config.libdir = config.libdir.replace('\\', '/')
 
-    def test_compile(flags) -> bool:
+    def test_compile(flags):
         """
-        Check whether GHC can compile in the given way.
-        This is used as a proxy to determine, e.g., whether
-        profiled libraries were built.
+        Check whether GHC can compile in the given way. This is used as a
+        proxy to determine, e.g., whether profiled libraries were built, or
+        whether the host RTS supports smp.
         """
         import tempfile
         import textwrap
@@ -231,13 +230,28 @@ def get_compiler_info():
                     '{} -v0 {} -o test '.format(config.compiler, src) + ' '.join(flags),
                     shell=True,
                     cwd=d,
-                    stderr=None if config.verbose >= 3 else subprocess.DEVNULL)
-            res = p.returncode
-            return res == 0
-
-    config.have_vanilla = test_compile([])
-    config.have_dynamic = test_compile(['-dynamic'])
-    config.have_profiling = test_compile(['-prof'])
+                    capture_output=True
+                    )
+            return p # return the subprocess result. Consumers may have different
+                     # needs
+
+    def compiler_supports_way(flags):
+        return test_compile(flags).returncode == 0
+
+    # Test the Host RTS to determine if it supports SMP. For cross compilers the
+    # Host /= Target, so we cannot determine from the ghcconfig file if the host
+    # itself supports smp. To support smp the host must be linked with an RTS
+    # built with 'defined(THREADED_RTS) && !defined(NO_SMP)'. Thus we directly
+    # query the RTS the host is linked with.
+    p = test_compile(["+RTS", "--a-dummy-flag-to-err-with"])
+
+    # try to find the -N flag in tho help output
+    supported = re.search("-N\[<n>\]" , p.stderr.decode("utf-8"))
+    config.host_has_smp = True if supported else False
+
+    config.have_vanilla   = compiler_supports_way([])
+    config.have_dynamic   = compiler_supports_way(['-dynamic'])
+    config.have_profiling = compiler_supports_way(['-prof'])
 
     if config.have_profiling:
         config.compile_ways.append('profasm')


=====================================
testsuite/driver/testglobals.py
=====================================
@@ -147,11 +147,11 @@ class TestConfig:
         # Is the compiler dynamically linked?
         self.ghc_dynamic = False
 
-        # Does the bootstrapping ghc  we have SMP support?
-        self.ghc_has_smp = False
+        # Does the host RTS have SMP support?
+        self.host_has_smp = True
 
         # Does the target have SMP support?
-        self.target_with_smp = False
+        self.target_with_smp = True
 
         # Is gdb available?
         self.have_gdb = False



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9401f218c3862c0821bcbc2481aabb2b4f4ed04
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/20221222/cec02128/attachment-0001.html>


More information about the ghc-commits mailing list