[libcxx-commits] [libcxx] e938943 - [libc++] Fix locale-related compilation errors on NetBSD (#143055)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Oct 29 13:31:00 PDT 2025
Author: Alex Rønne Petersen
Date: 2025-10-29T21:30:54+01:00
New Revision: e9389436e5eaeae6934316591331d843a9dc366c
URL: https://github.com/llvm/llvm-project/commit/e9389436e5eaeae6934316591331d843a9dc366c
DIFF: https://github.com/llvm/llvm-project/commit/e9389436e5eaeae6934316591331d843a9dc366c.diff
LOG: [libc++] Fix locale-related compilation errors on NetBSD (#143055)
To my knowledge, NetBSD is mostly like other BSDs, but doesn't have
`xlocale.h`. I think c664a7f may have inadvertently broken this.
With this change, I was able to run
[zig-bootstrap](https://github.com/ziglang/zig-bootstrap) to completion
for `x86_64-netbsd10.1-none`.
Added:
libcxx/include/__locale_dir/support/netbsd.h
Modified:
libcxx/include/CMakeLists.txt
libcxx/include/__locale_dir/locale_base_api.h
libcxx/include/__locale_dir/support/bsd_like.h
libcxx/include/module.modulemap.in
Removed:
################################################################################
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 37259a7e6e7dd..de9819cf5346a 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -529,6 +529,7 @@ set(files
__locale_dir/support/freebsd.h
__locale_dir/support/fuchsia.h
__locale_dir/support/linux.h
+ __locale_dir/support/netbsd.h
__locale_dir/support/no_locale/characters.h
__locale_dir/support/no_locale/strtonum.h
__locale_dir/support/windows.h
diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h
index 9f3ce02a3af20..8c8f00061d1ed 100644
--- a/libcxx/include/__locale_dir/locale_base_api.h
+++ b/libcxx/include/__locale_dir/locale_base_api.h
@@ -115,6 +115,8 @@
# include <__locale_dir/support/apple.h>
# elif defined(__FreeBSD__)
# include <__locale_dir/support/freebsd.h>
+# elif defined(__NetBSD__)
+# include <__locale_dir/support/netbsd.h>
# elif defined(_LIBCPP_MSVCRT_LIKE)
# include <__locale_dir/support/windows.h>
# elif defined(__Fuchsia__)
diff --git a/libcxx/include/__locale_dir/support/bsd_like.h b/libcxx/include/__locale_dir/support/bsd_like.h
index ac402924709e5..9d4bdd1d5775f 100644
--- a/libcxx/include/__locale_dir/support/bsd_like.h
+++ b/libcxx/include/__locale_dir/support/bsd_like.h
@@ -24,7 +24,9 @@
# include <wctype.h>
#endif
-#include <xlocale.h>
+#if __has_include(<xlocale.h>)
+# include <xlocale.h>
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__locale_dir/support/netbsd.h b/libcxx/include/__locale_dir/support/netbsd.h
new file mode 100644
index 0000000000000..190857f6f84fe
--- /dev/null
+++ b/libcxx/include/__locale_dir/support/netbsd.h
@@ -0,0 +1,20 @@
+//===-----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H
+#define _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#include <__locale_dir/support/bsd_like.h>
+
+#endif // _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index a86d6c6a43d0e..11ab61d959e22 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1587,6 +1587,7 @@ module std [system] {
textual header "__locale_dir/support/freebsd.h"
textual header "__locale_dir/support/fuchsia.h"
textual header "__locale_dir/support/linux.h"
+ textual header "__locale_dir/support/netbsd.h"
textual header "__locale_dir/support/no_locale/characters.h"
textual header "__locale_dir/support/no_locale/strtonum.h"
textual header "__locale_dir/support/windows.h"
More information about the libcxx-commits
mailing list