diff --git a/testsuite/config/ghc b/testsuite/config/ghc index 01d1fcf14e9dba0e66c92e2dc01871c18f973aad..90b11bc57fc49591d4ffea76f4d469459c060ab2 100644 --- a/testsuite/config/ghc +++ b/testsuite/config/ghc @@ -223,7 +223,7 @@ def get_compiler_info(): # See Note [Replacing backward slashes in config.libdir]. config.libdir = config.libdir.replace('\\', '/') - def test_compile(flags): + def test_compile(flags, test_filename='test.hs', test_src=None): """ 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 @@ -234,12 +234,15 @@ def get_compiler_info(): res = False - with tempfile.TemporaryDirectory() as d: - src = Path(d) / 'test.hs' - src.write_text(textwrap.dedent(''' + if test_src is None: + test_src = ''' module Main where main = putStrLn "Hello World!" - ''')) + ''' + + with tempfile.TemporaryDirectory() as d: + src = Path(d) / test_filename + src.write_text(textwrap.dedent(test_src)) try: p = subprocess.run( '{} -v0 {} -o test '.format(config.compiler, src) + ' '.join(flags), @@ -295,6 +298,16 @@ def get_compiler_info(): config.plugin_way_flags = "-static" config.ghc_th_way = "normal" + config.cmm_cpp_is_gcc = test_compile( + ['-c'], + test_filename='test.cmm', + test_src=''' + #if defined(__clang__) || !defined(__GNUC__) + # error "not gcc" + #endif + ''' + ) + # Note [Replacing backward slashes in config.libdir] # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # diff --git a/testsuite/driver/testglobals.py b/testsuite/driver/testglobals.py index 8617841a5573cf1fda46fb326c8363c6c3bcfd85..d515a0e7e0e1203c5ef623459781d487e29340de 100644 --- a/testsuite/driver/testglobals.py +++ b/testsuite/driver/testglobals.py @@ -232,6 +232,9 @@ class TestConfig: # The path specifies the file in which to write the dependencies self.only_report_hadrian_deps = None # type: Optional[Path] + # Are we using GCC to preprocess C--? + self.cmm_cpp_is_gcc = False + def validate(self) -> None: """ Check the TestConfig for self-consistency """ def assert_implies(a: bool, b: bool): diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index db157ae0f277b8fbdecbc8b7b006324ed83f8f62..7ba54da41589db73078131d37f83b6a98b6fda89 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -996,6 +996,10 @@ def llvm_build ( ) -> bool: def have_thread_sanitizer( ) -> bool: return config.have_thread_sanitizer + +def gcc_as_cmmp() -> bool: + return config.cmm_cpp_is_gcc + # --- # Note [Measuring residency]