[libcxx-commits] [libcxx] 337e633 - [libcxx] [test] Detect mingw-w64 headers compatible with C++ module builds (#92893)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 21 12:34:42 PDT 2024
Author: Martin Storsjö
Date: 2024-05-21T22:34:38+03:00
New Revision: 337e633bb75640bb6e04eb874c7114dfac6fa754
URL: https://github.com/llvm/llvm-project/commit/337e633bb75640bb6e04eb874c7114dfac6fa754
DIFF: https://github.com/llvm/llvm-project/commit/337e633bb75640bb6e04eb874c7114dfac6fa754.diff
LOG: [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.
Added:
Modified:
libcxx/utils/libcxx/test/features.py
Removed:
################################################################################
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index c81b56b1af547..093cd39ea64c6 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 @@ def _getAndroidDeviceApi(cfg):
# 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"),
More information about the libcxx-commits
mailing list