-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc++] Fix compilation for NetBSD. #143055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
cc @ldionne |
@llvm/pr-subscribers-libcxx Author: Alex Rønne Petersen (alexrp) ChangesTo my knowledge, NetBSD is mostly like other BSDs, but doesn't have Full diff: https://github.com/llvm/llvm-project/pull/143055.diff 5 Files Affected:
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/apple.h b/libcxx/include/__locale_dir/support/apple.h
index 62eb79c30d435..5216ed2ba758a 100644
--- a/libcxx/include/__locale_dir/support/apple.h
+++ b/libcxx/include/__locale_dir/support/apple.h
@@ -15,6 +15,8 @@
# pragma GCC system_header
#endif
+#include <xlocale.h>
+
#include <__locale_dir/support/bsd_like.h>
#endif // _LIBCPP___LOCALE_DIR_SUPPORT_APPLE_H
diff --git a/libcxx/include/__locale_dir/support/bsd_like.h b/libcxx/include/__locale_dir/support/bsd_like.h
index 54eb397358d7a..e9168c91b4fb3 100644
--- a/libcxx/include/__locale_dir/support/bsd_like.h
+++ b/libcxx/include/__locale_dir/support/bsd_like.h
@@ -24,8 +24,6 @@
# include <wctype.h>
#endif
-#include <xlocale.h>
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/__locale_dir/support/freebsd.h b/libcxx/include/__locale_dir/support/freebsd.h
index 5c6e21e387271..5e24cbd29bb5a 100644
--- a/libcxx/include/__locale_dir/support/freebsd.h
+++ b/libcxx/include/__locale_dir/support/freebsd.h
@@ -15,6 +15,8 @@
# pragma GCC system_header
#endif
+#include <xlocale.h>
+
#include <__locale_dir/support/bsd_like.h>
#endif // _LIBCPP___LOCALE_DIR_SUPPORT_FREEBSD_H
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
|
To my knowledge, NetBSD is mostly like other BSDs, but doesn't have xlocale.h. I think c664a7f may have inadvertently broken this.
nit: we don't use trailing period in commit messages :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meta comment: the reason this code was removed is that it was seen as dead code. We don't have CI builders for NetBSD and we also don't officially support that platform (https://libcxx.llvm.org/#platform-and-compiler-support). It's not that we don't want to, but we require at least one CI runner to exist in order to officially support a platform so that we can ensure that stuff works.
Is that something that NetBSD would be able to provide?
@@ -24,8 +24,6 @@ | |||
# include <wctype.h> | |||
#endif | |||
|
|||
#include <xlocale.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are functions like strtof_l
defined on NetBSD? We need each header to include what it uses: moving this include up the stack means that bsd_like.h
is technically missing an include on Apple and FreeBSD. Instead, we should probably do
#if __has_include(<xlocale.h>)
# include <xlocale.h>
#endif
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 to completion for
x86_64-netbsd10.1-none
.