[libcxx] [test] Check for C++ headers before building a test that uses them
authorMartin Storsjö <martin@martin.st>
Wed, 29 Mar 2023 21:35:56 +0000 (00:35 +0300)
committerMartin Storsjö <martin@martin.st>
Wed, 12 Apr 2023 07:16:50 +0000 (10:16 +0300)
When the libcxx test framework is executed within libunwind, there
are no standard C++ headers available (libunwind builds with
-nostdinc++, but doesn't add any libcxx headers to the include path).

Check that a test that includes <iostream> can be compiled before trying
to build and execute a test program that includes it.

Previously, the compile error here would block all libunwind tests from
executing altogether.

Differential Revision: https://reviews.llvm.org/D147630

libcxx/utils/libcxx/test/features.py

index 9d031ff..dd5163f 100644 (file)
@@ -240,7 +240,10 @@ for locale, alts in locales.items():
 DEFAULT_FEATURES += [
   Feature(name='darwin', when=lambda cfg: '__APPLE__' in compilerMacros(cfg)),
   Feature(name='windows', when=lambda cfg: '_WIN32' in compilerMacros(cfg)),
-  Feature(name='windows-dll', when=lambda cfg: '_WIN32' in compilerMacros(cfg) and programSucceeds(cfg, """
+  Feature(name='windows-dll', when=lambda cfg: '_WIN32' in compilerMacros(cfg) and sourceBuilds(cfg, """
+            #include <iostream>
+            int main(int, char**) { return 0; }
+          """) and programSucceeds(cfg, """
             #include <iostream>
             #include <windows.h>
             #include <winnt.h>