[libc-commits] [libc] [libc][MacOS] Enable wchar conversion and rpc_server (PR #191065)
via libc-commits
libc-commits at lists.llvm.org
Wed Apr 8 15:15:51 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Michael Jones (michaelrj-google)
<details>
<summary>Changes</summary>
Originally the wchar conversion was disabled due to MacOS not providing
uchar.h. We only needed it for char32_t so this PR just provides it
directly from our headers on MacOS. This also fixes fwrite_unlocked not
being available on MacOS which is needed for rpc_server.h.
---
Full diff: https://github.com/llvm/llvm-project/pull/191065.diff
4 Files Affected:
- (modified) libc/hdr/types/char32_t.h (+6-1)
- (modified) libc/shared/rpc_server.h (+4)
- (modified) libc/src/__support/CMakeLists.txt (+2-6)
- (modified) libc/test/src/__support/CMakeLists.txt (+2-6)
``````````diff
diff --git a/libc/hdr/types/char32_t.h b/libc/hdr/types/char32_t.h
index 94fe5747d3415..df629d44edd3b 100644
--- a/libc/hdr/types/char32_t.h
+++ b/libc/hdr/types/char32_t.h
@@ -15,8 +15,13 @@
#else // overlay mode
+// MacOS doesn't provide uchar.h so we use the types provided by LLVM-libc.
+#ifdef __APPLE__
+#include "include/llvm-libc-types/char32_t.h"
+#else
#include "hdr/uchar_overlay.h"
+#endif
-#endif // LLVM_LIBC_FULL_BUILD
+#endif // LIBC_FULL_BUILD
#endif // LLVM_LIBC_HDR_TYPES_CHAR32_T_H
diff --git a/libc/shared/rpc_server.h b/libc/shared/rpc_server.h
index ad72eb16c74fa..175f91dd34b01 100644
--- a/libc/shared/rpc_server.h
+++ b/libc/shared/rpc_server.h
@@ -20,6 +20,10 @@
#define flockfile _lock_file
#define funlockfile _unlock_file
#define fwrite_unlocked _fwrite_nolock
+#elif defined(__APPLE__)
+// MacOS doesn't have an equivalent of fwrite_unlocked so we just use
+// fwrite.
+#define fwrite_unlocked fwrite
#endif
namespace rpc {
diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index 08a4db8e49a73..ce69d4e6f69ac 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -452,12 +452,8 @@ add_subdirectory(fixed_point)
add_subdirectory(time)
-# Requires access to uchar header which is not on macos
-# Therefore, cannot currently build this on macos in overlay mode
-if(NOT (LIBC_TARGET_OS_IS_DARWIN))
- add_subdirectory(wchar)
- add_subdirectory(wctype)
-endif()
+add_subdirectory(wchar)
+add_subdirectory(wctype)
add_subdirectory(math)
if(LIBC_COMPILER_HAS_EXT_VECTOR_TYPE)
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 64e15852c2ec3..6b9c1b4ac8cc7 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -311,9 +311,5 @@ add_subdirectory(fixed_point)
add_subdirectory(HashTable)
add_subdirectory(time)
add_subdirectory(threads)
-# Requires access to uchar header which is not on MacOS
-# Cannot currently build this on MacOS in overlay mode
-if(NOT(LIBC_TARGET_OS_IS_DARWIN))
- add_subdirectory(wchar)
- add_subdirectory(wctype)
-endif()
+add_subdirectory(wchar)
+add_subdirectory(wctype)
``````````
</details>
https://github.com/llvm/llvm-project/pull/191065
More information about the libc-commits
mailing list