[libcxx-commits] [libcxx] [libc++] Add implementations of __get_locale_encoding(...) to Fuschia and LLVM-Libc (PR #205716)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 24 19:52:58 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: William Tran-Viet (smallp-o-p)
<details>
<summary>Changes</summary>
- These were missed in #<!-- -->141312 and consequently broke the Fuschia and AMDGPU llvm-libc build bots.
- Fuschia seems to have support for `nl_langinfo_l(...)`, so we can use that.
- However, LLVM-libc does not implement it, so for now we can mark `environment()` and `encoding()` as unsupported on LLVM libc.
---
Full diff: https://github.com/llvm/llvm-project/pull/205716.diff
4 Files Affected:
- (modified) libcxx/include/__locale_dir/support/fuchsia.h (+5)
- (modified) libcxx/include/__locale_dir/support/llvm_libc.h (+2)
- (modified) libcxx/test/libcxx/text/text_encoding/environment.pass.cpp (+1)
- (modified) libcxx/test/std/text/text_encoding/text_encoding.members/environment.pass.cpp (+1)
``````````diff
diff --git a/libcxx/include/__locale_dir/support/fuchsia.h b/libcxx/include/__locale_dir/support/fuchsia.h
index 528bfeb0cb6e1..e2e97a77c6c46 100644
--- a/libcxx/include/__locale_dir/support/fuchsia.h
+++ b/libcxx/include/__locale_dir/support/fuchsia.h
@@ -15,6 +15,7 @@
#include <cstdio>
#include <cstdlib>
#include <cwchar>
+#include <langinfo.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -69,6 +70,10 @@ inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) {
return std::localeconv();
}
+inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding([[maybe_unused]] __locale_t __loc) {
+ return ::nl_langinfo_l(CODESET, __loc);
+}
+
//
// Other functions
//
diff --git a/libcxx/include/__locale_dir/support/llvm_libc.h b/libcxx/include/__locale_dir/support/llvm_libc.h
index 1ce1c443d87ed..d4a88f7e51191 100644
--- a/libcxx/include/__locale_dir/support/llvm_libc.h
+++ b/libcxx/include/__locale_dir/support/llvm_libc.h
@@ -47,6 +47,8 @@ inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __loc
}
inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t&) { return std::localeconv(); }
+
+inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding([[maybe_unused]] __locale_t) { return nullptr; }
#endif // _LIBCPP_BUILDING_LIBRARY
} // namespace __locale
diff --git a/libcxx/test/libcxx/text/text_encoding/environment.pass.cpp b/libcxx/test/libcxx/text/text_encoding/environment.pass.cpp
index b5c88c6e6d568..0bcabb235fc8b 100644
--- a/libcxx/test/libcxx/text/text_encoding/environment.pass.cpp
+++ b/libcxx/test/libcxx/text/text_encoding/environment.pass.cpp
@@ -14,6 +14,7 @@
// UNSUPPORTED: no-localization
// UNSUPPORTED: windows, android
// UNSUPPORTED: availability-te-environment-missing
+// UNSUPPORTED: LLVM-LIBC-FIXME
// std::text_encoding::environment()
diff --git a/libcxx/test/std/text/text_encoding/text_encoding.members/environment.pass.cpp b/libcxx/test/std/text/text_encoding/text_encoding.members/environment.pass.cpp
index 113b151765c81..8907f72b55140 100644
--- a/libcxx/test/std/text/text_encoding/text_encoding.members/environment.pass.cpp
+++ b/libcxx/test/std/text/text_encoding/text_encoding.members/environment.pass.cpp
@@ -11,6 +11,7 @@
// UNSUPPORTED: no-localization
// UNSUPPORTED: availability-te-environment-missing
+// UNSUPPORTED: LLVM-LIBC-FIXME
// <text_encoding>
``````````
</details>
https://github.com/llvm/llvm-project/pull/205716
More information about the libcxx-commits
mailing list