From 6311f039b2678f0a1367a88679efb7b2e37949dc Mon Sep 17 00:00:00 2001 From: Uzair Nawaz Date: Thu, 12 Jun 2025 17:34:45 +0000 Subject: [PATCH] [libc] Build fixes for widechar characterconverter (#143805) Build fixes for wchar CharacterConverter class --- libc/hdr/CMakeLists.txt | 2 ++ libc/hdr/types/CMakeLists.txt | 22 ++++++++++++++++++++++ libc/include/llvm-libc-types/char8_t.h | 3 +-- libc/src/__support/CMakeLists.txt | 2 ++ libc/src/__support/wchar/mbstate.h | 1 + libc/src/__support/wchar/utf_ret.h | 5 ++++- 6 files changed, 32 insertions(+), 3 deletions(-) diff --git a/libc/hdr/CMakeLists.txt b/libc/hdr/CMakeLists.txt index 1e9f59621a8e..052a773a4fce 100644 --- a/libc/hdr/CMakeLists.txt +++ b/libc/hdr/CMakeLists.txt @@ -221,6 +221,8 @@ add_proxy_header_library( add_header_library(wchar_overlay HDRS wchar_overlay.h) +add_header_library(uchar_overlay HDRS uchar_overlay.h) + add_proxy_header_library( wchar_macros HDRS diff --git a/libc/hdr/types/CMakeLists.txt b/libc/hdr/types/CMakeLists.txt index 5f6197c93d44..c88c35700907 100644 --- a/libc/hdr/types/CMakeLists.txt +++ b/libc/hdr/types/CMakeLists.txt @@ -1,3 +1,25 @@ +add_proxy_header_library( + char8_t + HDRS + char8_t.h + DEPENDS + libc.hdr.uchar_overlay + FULL_BUILD_DEPENDS + libc.include.llvm-libc-types.char8_t + libc.include.uchar +) + +add_proxy_header_library( + char32_t + HDRS + char32_t.h + DEPENDS + libc.hdr.uchar_overlay + FULL_BUILD_DEPENDS + libc.include.llvm-libc-types.char32_t + libc.include.uchar +) + add_proxy_header_library( div_t HDRS diff --git a/libc/include/llvm-libc-types/char8_t.h b/libc/include/llvm-libc-types/char8_t.h index ddadab1afa21..a343be77d810 100644 --- a/libc/include/llvm-libc-types/char8_t.h +++ b/libc/include/llvm-libc-types/char8_t.h @@ -9,8 +9,7 @@ #ifndef LLVM_LIBC_TYPES_CHAR8_T_H #define LLVM_LIBC_TYPES_CHAR8_T_H -#if !defined(__cplusplus) && defined(__STDC_VERSION__) && \ - __STDC_VERSION__ >= 202311L +#if !(defined(__cplusplus) && defined(__cpp_char8_t)) typedef unsigned char char8_t; #endif diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt index 8cf2b0cdcdcc..309cde76370f 100644 --- a/libc/src/__support/CMakeLists.txt +++ b/libc/src/__support/CMakeLists.txt @@ -391,4 +391,6 @@ add_subdirectory(fixed_point) add_subdirectory(time) +add_subdirectory(wchar) + add_subdirectory(math) diff --git a/libc/src/__support/wchar/mbstate.h b/libc/src/__support/wchar/mbstate.h index 72ec72756000..cb8950374de4 100644 --- a/libc/src/__support/wchar/mbstate.h +++ b/libc/src/__support/wchar/mbstate.h @@ -10,6 +10,7 @@ #define LLVM_LIBC_SRC___SUPPORT_MBSTATE_H #include "hdr/types/char32_t.h" +#include "src/__support/common.h" #include namespace LIBC_NAMESPACE_DECL { diff --git a/libc/src/__support/wchar/utf_ret.h b/libc/src/__support/wchar/utf_ret.h index b8a8f6f09414..fa99b76159bd 100644 --- a/libc/src/__support/wchar/utf_ret.h +++ b/libc/src/__support/wchar/utf_ret.h @@ -9,13 +9,16 @@ #ifndef LLVM_LIBC_SRC___SUPPORT_UTF_RET_H #define LLVM_LIBC_SRC___SUPPORT_UTF_RET_H -namespace LIBC_NAMESPACE_DECL { +#include "src/__support/common.h" +namespace LIBC_NAMESPACE_DECL { +namespace internal { template struct utf_ret { T out; int error; }; +} // namespace internal } // namespace LIBC_NAMESPACE_DECL #endif // LLVM_LIBC_SRC___SUPPORT_UTF_RET_H