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

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 20 09:47:58 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/176970.diff


1 Files Affected:

- (modified) libcxx/utils/libcxx/test/features/localization.py (+14-8) 


``````````diff
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
+              }
           """,
         ),
     ),

``````````

</details>


https://github.com/llvm/llvm-project/pull/176970


More information about the libcxx-commits mailing list