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

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 20 09:08:01 PST 2026


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/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.

>From ef17f2f138ba6ed48bab13a4d074dd7fd5de01be Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 20 Jan 2026 12:06:01 -0500
Subject: [PATCH] [libc++] Refactor the detection of
 glibc-old-ru_RU-decimal-point

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.
---
 .../libcxx/test/features/localization.py      | 22 ++++++++++++-------
 1 file changed, 14 insertions(+), 8 deletions(-)

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