@@ -38,6 +38,39 @@ def _getAndroidDeviceApi(cfg):
38
38
)
39
39
)
40
40
41
+
42
+ def _mingwSupportsModules (cfg ):
43
+ # Only mingw headers are known to work with libc++ built as a module,
44
+ # at the moment.
45
+ if not "__MINGW32__" in compilerMacros (cfg ):
46
+ return False
47
+ # For mingw headers, check for a version known to support being built
48
+ # as a module.
49
+ return sourceBuilds (
50
+ cfg ,
51
+ """
52
+ #include <_mingw_mac.h>
53
+ #if __MINGW64_VERSION_MAJOR < 12
54
+ #error Headers known to be incompatible
55
+ #elif __MINGW64_VERSION_MAJOR == 12
56
+ // The headers were fixed to work with libc++ modules during
57
+ // __MINGW64_VERSION_MAJOR == 12. The headers became compatible
58
+ // with libc++ built as a module in
59
+ // 1652e9241b5d8a5a779c6582b1c3c4f4a7cc66e5 (Apr 2024), but the
60
+ // following commit 8c13b28ace68f2c0094d45121d59a4b951b533ed
61
+ // removed the now unused __mingw_static_ovr define. Use this
62
+ // as indicator for whether we've got new enough headers.
63
+ #ifdef __mingw_static_ovr
64
+ #error Headers too old
65
+ #endif
66
+ #else
67
+ // __MINGW64_VERSION_MAJOR > 12 should be ok.
68
+ #endif
69
+ int main() { return 0; }
70
+ """ ,
71
+ )
72
+
73
+
41
74
# Lit features are evaluated in order. Some checks may require the compiler detection to have
42
75
# run first in order to work properly.
43
76
DEFAULT_FEATURES = [
@@ -281,7 +314,7 @@ def _getAndroidDeviceApi(cfg):
281
314
# Any declaration of a library function shall have external linkage.
282
315
when = lambda cfg : "__ANDROID__" in compilerMacros (cfg )
283
316
or "__FreeBSD__" in compilerMacros (cfg )
284
- or "_WIN32" in compilerMacros (cfg )
317
+ or ( "_WIN32" in compilerMacros (cfg ) and not _mingwSupportsModules ( cfg ) )
285
318
or platform .system ().lower ().startswith ("aix" )
286
319
# Avoid building on platforms that don't support modules properly.
287
320
or not hasCompileFlag (cfg , "-Wno-reserved-module-identifier" ),
0 commit comments