[Git][ghc/ghc][wip/req_smp] test the RTS in config/ghc not hadrian
doyougnu (@doyougnu)
gitlab at gitlab.haskell.org
Thu Dec 22 17:38:58 UTC 2022
doyougnu pushed to branch wip/req_smp at Glasgow Haskell Compiler / GHC
Commits:
1294e45a by doyougnu at 2022-12-22T12:38:32-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
=====================================
@@ -1,6 +1,7 @@
# vim: set filetype=python:
import re
+import subprocess
# Testsuite configuration setup for GHC
#
@@ -43,12 +44,49 @@ if ghc_with_native_codegen:
if config.have_interp:
config.run_ways.append('ghci')
-if ghc_with_smp:
- config.ghc_has_smp = True
-
+def test_compile(flags) -> bool:
+ """
+ Check whether GHC can compile in the given way.
+ This is used as a proxy to determine, e.g., whether
+ profiled libraries were built.
+ """
+ import tempfile
+ import textwrap
+ with tempfile.TemporaryDirectory() as d:
+ src = Path(d) / 'test.hs'
+ src.write_text(textwrap.dedent('''
+ module Main where
+ main = putStrLn "Hello World!"
+ '''))
+ p = subprocess.run(
+ '{} -v0 {} -o test '.format(config.compiler, src) + ' '.join(flags),
+ shell=True,
+ cwd=d, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
+ )
+ return p
+
+def get_host_smp_info():
+ """
+ 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", "--help"])
+ print(p)
+
+ return True
+
+# Query whether the host RTS (not the target) supports smp
+config.host_has_smp = get_host_smp_info()
+
+# 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:
=====================================
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/1294e45a8b19d16799805f8cba9d395dddff2a91
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1294e45a8b19d16799805f8cba9d395dddff2a91
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/b30bb078/attachment-0001.html>
More information about the ghc-commits
mailing list