[libcxx-commits] [libcxx] fb6c04c - [libc++] Refactor the detection of glibc-old-ru_RU-decimal-point (#176970)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 21 06:28:58 PST 2026


Author: Louis Dionne
Date: 2026-01-21T09:28:52-05:00
New Revision: fb6c04cb4ef69d6119927d4c151a7009264dd810

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

LOG: [libc++] Refactor the detection of glibc-old-ru_RU-decimal-point (#176970)

This refactor simplifies the logic by moving the #ifdef checks to the
program itself, and fixes configuration errors in cases where <locale.h>
does not exist on the system.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/libcxx/test/features/localization.py b/libcxx/utils/libcxx/test/features/localization.py
index 157c250429d27..88e240798d271 100644
--- a/libcxx/utils/libcxx/test/features/localization.py
+++ b/libcxx/utils/libcxx/test/features/localization.py
@@ -14,17 +14,23 @@
     # mon_decimal_point == ".", which our tests don't handle.
     Feature(
         name="glibc-old-ru_RU-decimal-point",
-        when=lambda cfg: not "_LIBCPP_HAS_LOCALIZATION" in compilerMacros(cfg)
-        or compilerMacros(cfg)["_LIBCPP_HAS_LOCALIZATION"] == "1"
-        and not programSucceeds(
+        when=lambda cfg: programSucceeds(
             cfg,
             """
-            #include <locale.h>
+            #include <stdlib.h>
             #include <string.h>
-            int main(int, char**) {
-              setlocale(LC_ALL, "ru_RU.UTF-8");
-              return strcmp(localeconv()->mon_decimal_point, ",");
-            }
+            #if __has_include(<locale.h>)
+              #include <locale.h>
+            #endif
+
+              int main(int, char**) {
+            #if __has_include(<locale.h>) && (!defined(_LIBCPP_HAS_LOCALIZATION) || _LIBCPP_HAS_LOCALIZATION == 1)
+                setlocale(LC_ALL, "ru_RU.UTF-8");
+                return strcmp(localeconv()->mon_decimal_point, ".") == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+            #else
+                return EXIT_FAILURE;
+            #endif
+              }
           """,
         ),
     ),


        


More information about the libcxx-commits mailing list