aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2024-05-21 22:34:38 +0300
committerGitHub <noreply@github.com>2024-05-21 22:34:38 +0300
commit337e633bb75640bb6e04eb874c7114dfac6fa754 (patch)
tree4d379ce7f4a16727e17feb6aff841c3cf623361d
parent87a6865d2c8eba802a7e9f42fa8b6ac1edd0664e (diff)
downloadllvm-337e633bb75640bb6e04eb874c7114dfac6fa754.zip
llvm-337e633bb75640bb6e04eb874c7114dfac6fa754.tar.gz
llvm-337e633bb75640bb6e04eb874c7114dfac6fa754.tar.bz2
[libcxx] [test] Detect mingw-w64 headers compatible with C++ module builds (#92893)
This fixes running the tests/CI with a newer mingw toolchain that has been fixed to work with building libc++ as a module.
-rw-r--r--libcxx/utils/libcxx/test/features.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index c81b56b..093cd39 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -38,6 +38,39 @@ def _getAndroidDeviceApi(cfg):
)
)
+
+def _mingwSupportsModules(cfg):
+ # Only mingw headers are known to work with libc++ built as a module,
+ # at the moment.
+ if not "__MINGW32__" in compilerMacros(cfg):
+ return False
+ # For mingw headers, check for a version known to support being built
+ # as a module.
+ return sourceBuilds(
+ cfg,
+ """
+ #include <_mingw_mac.h>
+ #if __MINGW64_VERSION_MAJOR < 12
+ #error Headers known to be incompatible
+ #elif __MINGW64_VERSION_MAJOR == 12
+ // The headers were fixed to work with libc++ modules during
+ // __MINGW64_VERSION_MAJOR == 12. The headers became compatible
+ // with libc++ built as a module in
+ // 1652e9241b5d8a5a779c6582b1c3c4f4a7cc66e5 (Apr 2024), but the
+ // following commit 8c13b28ace68f2c0094d45121d59a4b951b533ed
+ // removed the now unused __mingw_static_ovr define. Use this
+ // as indicator for whether we've got new enough headers.
+ #ifdef __mingw_static_ovr
+ #error Headers too old
+ #endif
+ #else
+ // __MINGW64_VERSION_MAJOR > 12 should be ok.
+ #endif
+ int main() { return 0; }
+ """,
+ )
+
+
# Lit features are evaluated in order. Some checks may require the compiler detection to have
# run first in order to work properly.
DEFAULT_FEATURES = [
@@ -281,7 +314,7 @@ DEFAULT_FEATURES = [
# Any declaration of a library function shall have external linkage.
when=lambda cfg: "__ANDROID__" in compilerMacros(cfg)
or "__FreeBSD__" in compilerMacros(cfg)
- or "_WIN32" in compilerMacros(cfg)
+ or ("_WIN32" in compilerMacros(cfg) and not _mingwSupportsModules(cfg))
or platform.system().lower().startswith("aix")
# Avoid building on platforms that don't support modules properly.
or not hasCompileFlag(cfg, "-Wno-reserved-module-identifier"),