[libcxx-commits] [libcxx] 0021505 - [libc++] Simplify detection of win32-broken-utf8-wchar-ctype (#214797)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 10 05:58:40 PDT 2026


Author: Louis Dionne
Date: 2026-08-10T08:58:34-04:00
New Revision: 00215059cc71b7a229c2d2fc70797018b927514c

URL: https://github.com/llvm/llvm-project/commit/00215059cc71b7a229c2d2fc70797018b927514c
DIFF: https://github.com/llvm/llvm-project/commit/00215059cc71b7a229c2d2fc70797018b927514c.diff

LOG: [libc++] Simplify detection of win32-broken-utf8-wchar-ctype (#214797)

Instead of querying `_LIBCPP_HAS_LOCALIZATION` from Python, do it from
the source program. This fixes a bug where if `_LIBCPP_HAS_LOCALIZATION`
was not defined at all (which is the case for older versions of libc++),
the feature would then be defined immediately, regardless of the
platform we're on. That's because `and` has higher precedence than `or`
in Python, so we'd end up skipping the `_WIN32` check entirely.

Added: 
    

Modified: 
    libcxx/utils/libcxx/test/features/misc.py

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/libcxx/test/features/misc.py b/libcxx/utils/libcxx/test/features/misc.py
index 3701498f595dc..318765e527089 100644
--- a/libcxx/utils/libcxx/test/features/misc.py
+++ b/libcxx/utils/libcxx/test/features/misc.py
@@ -122,17 +122,23 @@ def _mingwSupportsModules(cfg):
     # https://developercommunity.visualstudio.com/t/utf-8-locales-break-ctype-functions-for-wchar-type/1653678
     Feature(
         name="win32-broken-utf8-wchar-ctype",
-        when=lambda cfg: not "_LIBCPP_HAS_LOCALIZATION" in compilerMacros(cfg)
-        or compilerMacros(cfg)["_LIBCPP_HAS_LOCALIZATION"] == "1"
-        and "_WIN32" in compilerMacros(cfg)
-        and not programSucceeds(
+        when=lambda cfg: "_WIN32" in compilerMacros(cfg)
+        and programSucceeds(
             cfg,
             """
-            #include <locale.h>
+            #if __has_include(<locale.h>)
+            # include <locale.h>
+            #endif
+            #include <stdlib.h>
             #include <wctype.h>
+
             int main(int, char**) {
+            #if !defined(_LIBCPP_VERSION) || (defined(_LIBCPP_HAS_LOCALIZATION) && _LIBCPP_HAS_LOCALIZATION)
               setlocale(LC_ALL, "en_US.UTF-8");
-              return towlower(L'\\xDA') != L'\\xFA';
+              return towlower(L'\\xDA') == L'\\xFA' ? EXIT_FAILURE : EXIT_SUCCESS;
+            #else
+              return EXIT_FAILURE; // no localization: assume bug not present
+            #endif
             }
           """,
         ),


        


More information about the libcxx-commits mailing list