From 47beb1e57f398ee8a92ec837674f8244baa7c0cc Mon Sep 17 00:00:00 2001 From: Cheng Shao <terrorjack@type.dance> Date: Mon, 7 Oct 2024 16:30:59 +0000 Subject: [PATCH] hadrian/testsuite: implement config.cross logic This commit implements the config.cross field in the testsuite driver. It comes from the "cross compiling" ghc info field for both in-tree/out-of-tree GHC, and is an accurate predicate of whether we're cross-compiling or not (compared to the precense of target emulator), and is useful to implement predicates to assert the precense of internal interpreter (only available on non-cross GHC) for tests that do require it (e.g. plugins). (cherry picked from commit 2956a3f7ecd58a6fda81447100404941c0ed837d) --- hadrian/src/Oracles/TestSettings.hs | 3 ++- hadrian/src/Settings/Builders/RunTest.hs | 3 +++ testsuite/driver/testglobals.py | 3 +++ testsuite/ghc-config/ghc-config.hs | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hadrian/src/Oracles/TestSettings.hs b/hadrian/src/Oracles/TestSettings.hs index a56e656d6d6..98da420fb33 100644 --- a/hadrian/src/Oracles/TestSettings.hs +++ b/hadrian/src/Oracles/TestSettings.hs @@ -30,6 +30,7 @@ data TestSetting = TestHostOS | TestGhcDebugAssertions | TestGhcWithNativeCodeGen | TestGhcWithInterpreter + | TestGhcCrossCompiling | TestGhcWithRtsLinker | TestGhcUnregisterised | TestGhcTablesNextToCode @@ -61,6 +62,7 @@ testSetting key = do TestGhcDebugAssertions -> "GhcDebugAssertions" TestGhcWithNativeCodeGen -> "GhcWithNativeCodeGen" TestGhcWithInterpreter -> "GhcWithInterpreter" + TestGhcCrossCompiling -> "CrossCompiling" TestGhcWithRtsLinker -> "GhcWithRtsLinker" TestGhcUnregisterised -> "GhcUnregisterised" TestGhcTablesNextToCode -> "GhcTablesNextToCode" @@ -124,4 +126,3 @@ stageOfTestCompiler "stage1" = Just stage0InTree stageOfTestCompiler "stage2" = Just Stage1 stageOfTestCompiler "stage3" = Just Stage2 stageOfTestCompiler _ = Nothing - diff --git a/hadrian/src/Settings/Builders/RunTest.hs b/hadrian/src/Settings/Builders/RunTest.hs index b2828651ba5..9f90c30328c 100644 --- a/hadrian/src/Settings/Builders/RunTest.hs +++ b/hadrian/src/Settings/Builders/RunTest.hs @@ -67,6 +67,7 @@ data TestCompilerArgs = TestCompilerArgs{ , leadingUnderscore :: Bool , withNativeCodeGen :: Bool , withInterpreter :: Bool + , cross :: Bool , unregisterised :: Bool , tables_next_to_code :: Bool , targetWithSMP :: Bool -- does the target support SMP @@ -158,6 +159,7 @@ outOfTreeCompilerArgs = do leadingUnderscore <- getBooleanSetting TestLeadingUnderscore withNativeCodeGen <- getBooleanSetting TestGhcWithNativeCodeGen withInterpreter <- getBooleanSetting TestGhcWithInterpreter + cross <- getBooleanSetting TestGhcCrossCompiling unregisterised <- getBooleanSetting TestGhcUnregisterised tables_next_to_code <- getBooleanSetting TestGhcTablesNextToCode targetWithSMP <- targetSupportsSMP @@ -274,6 +276,7 @@ runTestBuilderArgs = builder Testsuite ? do , arg "-e", arg $ "config.have_interp=" ++ show withInterpreter + , arg "-e", arg $ "config.cross=" ++ show cross , arg "-e", arg $ "config.unregisterised=" ++ show unregisterised , arg "-e", arg $ "config.tables_next_to_code=" ++ show tables_next_to_code diff --git a/testsuite/driver/testglobals.py b/testsuite/driver/testglobals.py index 1fe5d1b2e94..b70937d1f5c 100644 --- a/testsuite/driver/testglobals.py +++ b/testsuite/driver/testglobals.py @@ -130,6 +130,9 @@ class TestConfig: # Do we have interpreter support? self.have_interp = False + # Are we cross-compiling? + self.cross = False + # Do we have RTS linker? self.have_RTS_linker = False diff --git a/testsuite/ghc-config/ghc-config.hs b/testsuite/ghc-config/ghc-config.hs index 0829991225a..c50090240ad 100644 --- a/testsuite/ghc-config/ghc-config.hs +++ b/testsuite/ghc-config/ghc-config.hs @@ -22,6 +22,7 @@ main = do getGhcFieldOrFail fields "GhcDebugAssertions" "Debug on" getGhcFieldOrFail fields "GhcWithNativeCodeGen" "Have native code generator" getGhcFieldOrFail fields "GhcWithInterpreter" "Have interpreter" + getGhcFieldOrFail fields "CrossCompiling" "cross compiling" getGhcFieldOrFail fields "GhcWithRtsLinker" "target has RTS linker" getGhcFieldOrFail fields "GhcUnregisterised" "Unregisterised" getGhcFieldOrFail fields "GhcWithSMP" "Support SMP" -- GitLab