[libcxx-commits] [libcxx] [libc++] Fix locale-related compilation errors on NetBSD (PR #143055)
Alex Rønne Petersen via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jun 14 15:29:26 PDT 2025
https://github.com/alexrp updated https://github.com/llvm/llvm-project/pull/143055
>From c64b80f5ecb700ef8616add574257062f2caa553 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= <alex at alexrp.com>
Date: Fri, 6 Jun 2025 02:56:30 +0200
Subject: [PATCH] [libc++] Fix locale-related compilation errors on NetBSD
To my knowledge, NetBSD is mostly like other BSDs, but doesn't have xlocale.h. I
think c664a7f may have inadvertently broken this.
---
libcxx/include/CMakeLists.txt | 1 +
libcxx/include/__locale_dir/locale_base_api.h | 2 ++
.../include/__locale_dir/support/bsd_like.h | 4 +++-
libcxx/include/__locale_dir/support/netbsd.h | 20 +++++++++++++++++++
libcxx/include/module.modulemap.in | 1 +
5 files changed, 27 insertions(+), 1 deletion(-)
create mode 100644 libcxx/include/__locale_dir/support/netbsd.h
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 8931a1b35f6d3..4fe9898902609 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -522,6 +522,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 bbc30b1cfe03f..c0ef6865fdee0 100644
--- a/libcxx/include/__locale_dir/locale_base_api.h
+++ b/libcxx/include/__locale_dir/locale_base_api.h
@@ -117,6 +117,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 54eb397358d7a..1e452fe3eb1e0 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 f5fd970934e9b..7bbdd4ea4ba71 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1560,6 +1560,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