[llvm-branch-commits] [libcxx] release/23.x: [libcxx] fix missing `__get_locale_encoding()` for OpenBSD (#228306) (PR #232746)

Douglas Yung via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Oct 22 22:47:22 PDT 2026


https://github.com/dyung updated https://github.com/llvm/llvm-project/pull/232746

>From 4247993ff888ee10ad62417d421ad0b53ded6d02 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= <alex at alexrp.com>
Date: Fri, 16 Oct 2026 15:28:54 +0200
Subject: [PATCH] [libcxx] fix missing `__get_locale_encoding()` for OpenBSD
 (#228306)

Fixes errors like this:

/home/alexrp/Sources/ziglang/zig-llvm23/lib/libcxx/src/text_encoding.cpp:34:43:
error: no member named '__get_locale_encoding' in namespace
        'std::__locale'
34 | return
__make_text_encoding(__locale::__get_locale_encoding(static_cast<__locale::__locale_t>(0)));
| ^~~~~~~~~~~~~~~~~~~~~

/home/alexrp/Sources/ziglang/zig-llvm23/lib/libcxx/src/text_encoding.cpp:48:41:
error: no member named '__get_locale_encoding' in namespace
        'std::__locale'
48 | return __make_text_encoding(__locale::__get_locale_encoding(__l));
        |                                         ^~~~~~~~~~~~~~~~~~~~~
    2 errors generated.

(cherry picked from commit 19f123540bfc1dc55f93d4dc22a3276b434f6cc4)
---
 libcxx/include/__locale_dir/support/openbsd.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libcxx/include/__locale_dir/support/openbsd.h b/libcxx/include/__locale_dir/support/openbsd.h
index 0ec5b12f2ebdde..57cb0d76174da1 100644
--- a/libcxx/include/__locale_dir/support/openbsd.h
+++ b/libcxx/include/__locale_dir/support/openbsd.h
@@ -24,6 +24,9 @@
 #  include <wchar.h>
 #  include <wctype.h>
 #endif
+#if defined(_LIBCPP_BUILDING_LIBRARY)
+#  include <langinfo.h>
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -74,6 +77,10 @@ inline __lconv_t* __localeconv(__locale_t& __loc) {
   __locale_guard __current(__loc);
   return ::localeconv();
 }
+
+inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t __loc) {
+  return ::nl_langinfo_l(CODESET, __loc);
+}
 #endif // _LIBCPP_BUILDING_LIBRARY
 
 //



More information about the llvm-branch-commits mailing list