Skip to content

Commit 4a2939f

Browse files
authored
[libcxx] Add downstream patch to enable char8_t related functions (#549)
LLVM libcxx does not define the `char8_t` related functions, instead delegating their definitions to the underlying C library. libcxx defines a macro called `_LIBCPP_HAS_C8RTOMB_MBRTOC8` when it infers that the underlying C library provides these functions. picolibc provides the `char8_t` related functions regardless of the C++ version used, but this support only landed after version 1.8.8 and, at the time of writing, has not made into any released version yet. This is a temporary fix and should be removed when a picolibc release includes the support for `char8_t` and its related functions. When it's time to implement a proper solution, one needs to create logic to detect the picolibc version and define the macro accordingly. The macros that govern picolibc version are in `picolibc.h`.
1 parent 4fbf466 commit 4a2939f

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
From 9011c0e821d5b1563dc2dc6370f29c529e55f41f Mon Sep 17 00:00:00 2001
2+
From: Victor Campos <[email protected]>
3+
Date: Thu, 31 Oct 2024 09:58:34 +0000
4+
Subject: Define _LIBCPP_HAS_C8RTOMB_MBRTOC8
5+
6+
LLVM libcxx does not define the `char8_t` related functions, instead
7+
delegating their definitions to the underlying C library.
8+
9+
libcxx defines a macro called `_LIBCPP_HAS_C8RTOMB_MBRTOC8` when it
10+
infers that the underlying C library provides these functions.
11+
12+
picolibc provides the `char8_t` related functions regardless of the C++
13+
version used, but this support only landed after version 1.8.8 and, at
14+
the time of writing, has not made into any released version yet.
15+
16+
This is a temporary fix and should be removed when a picolibc release
17+
includes the support for `char8_t` and its related functions. When it's
18+
time to implement a proper solution, one needs to create logic to detect
19+
the picolibc version and define the macro accordingly. The macros that
20+
govern picolibc version are in `picolibc.h`.
21+
---
22+
libcxx/include/__config | 17 ++---------------
23+
1 file changed, 2 insertions(+), 15 deletions(-)
24+
25+
diff --git a/libcxx/include/__config b/libcxx/include/__config
26+
index 1cf80a46686a..615433869a4e 100644
27+
--- a/libcxx/include/__config
28+
+++ b/libcxx/include/__config
29+
@@ -1021,21 +1021,8 @@ typedef __char32_t char32_t;
30+
// functions is gradually being added to existing C libraries. The conditions
31+
// below check for known C library versions and conditions under which these
32+
// functions are declared by the C library.
33+
-//
34+
-// GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if
35+
-// __cpp_char8_t is defined or if C2X extensions are enabled. Determining
36+
-// the latter depends on internal GNU libc details that are not appropriate
37+
-// to depend on here, so any declarations present when __cpp_char8_t is not
38+
-// defined are ignored.
39+
-# if defined(_LIBCPP_GLIBC_PREREQ)
40+
-# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
41+
-# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1
42+
-# else
43+
-# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
44+
-# endif
45+
-# else
46+
-# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
47+
-# endif
48+
+// For picolibc:
49+
+#define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1
50+
51+
// There are a handful of public standard library types that are intended to
52+
// support CTAD but don't need any explicit deduction guides to do so. This
53+
--
54+
2.43.0
55+

0 commit comments

Comments
 (0)