[libcxx-commits] [libcxx] [libcxx] Define _LIBCPP_HAS_C8RTOMB_MBRTOC8 for picolibc (PR #158648)
Victor Campos via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Sep 16 03:08:29 PDT 2025
https://github.com/vhscampos updated https://github.com/llvm/llvm-project/pull/158648
>From f4a7ec1573af5491ecfc44c67a1db45cdf2e8ec5 Mon Sep 17 00:00:00 2001
From: Victor Campos <victor.campos at arm.com>
Date: Thu, 7 Aug 2025 16:03:44 +0100
Subject: [PATCH] [libcxx] Define _LIBCPP_HAS_C8RTOMB_MBRTOC8 for picolibc
Starting from picolibc 1.8.9, the `char8_t` related functions are
provided.
This patch adds logic to detect the underlying picolibc version and
define the `_LIBCPP_HAS_C8RTOMB_MBRTOC8 macro` accordingly.
---
libcxx/include/__config | 2 ++
.../test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp | 5 +++++
libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp | 5 +++++
.../std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp | 6 ++++++
libcxx/utils/libcxx/test/features.py | 1 +
5 files changed, 19 insertions(+)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index b4c081dcdff1b..45f6852e379a7 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1027,6 +1027,8 @@ typedef __char32_t char32_t;
# else
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
# endif
+# elif defined(__clang__)
+# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1
# else
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
# endif
diff --git a/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp
index a1560c8ee5853..11da50665dc9f 100644
--- a/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp
+++ b/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp
@@ -11,6 +11,11 @@
// Apple platforms don't provide <uchar.h> yet, so these tests fail.
// XFAIL: target={{.+}}-apple-{{.+}}
+// The following platforms do not provide mbrtoc8 and c8rtomb so the tests fail
+// XFAIL: aix
+// XFAIL: freebsd
+// XFAIL: windows
+
// mbrtoc16 not defined.
// XFAIL: LIBCXX-PICOLIBC-FIXME
diff --git a/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp b/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp
index 2076384deb2b2..46c75e90c6780 100644
--- a/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp
+++ b/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp
@@ -11,6 +11,11 @@
// Apple platforms don't provide <uchar.h> yet, so these tests fail.
// XFAIL: target={{.+}}-apple-{{.+}}
+// The following platforms do not provide mbrtoc8 and c8rtomb so the tests fail
+// XFAIL: aix
+// XFAIL: freebsd
+// XFAIL: windows
+
// mbrtoc16 not defined.
// XFAIL: LIBCXX-PICOLIBC-FIXME
diff --git a/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp b/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp
index 1d4a225668d80..8ae31a658a63c 100644
--- a/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp
+++ b/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp
@@ -8,6 +8,12 @@
// UNSUPPORTED: c++03
+// The following platforms do not provide mbrtoc8 and c8rtomb so the tests fail
+// XFAIL: aix
+// XFAIL: darwin
+// XFAIL: freebsd
+// XFAIL: windows
+
#include <uchar.h>
#include "test_macros.h"
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index a964f3bdeeb46..d56816bfb2716 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -669,6 +669,7 @@ def _getLocaleFlagsAction(cfg, locale, alts, members):
""",
),
),
+ Feature(name="aix", when=lambda cfg: "_AIX" in compilerMacros(cfg)),
]
# Add features representing the build host platform name.
More information about the libcxx-commits
mailing list