-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[bazel] Improve libc build on macOS #86174
Conversation
@llvm/pr-subscribers-libc Author: Keith Smiley (keith) ChangesThis isn't enough to get everything in libc working, but I started down this path and these were the first required fixes. I might get back to more changes later. Full diff: https://github.com/llvm/llvm-project/pull/86174.diff 1 Files Affected:
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index c4f6eab0622181..59855dbef7bb05 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -742,12 +742,12 @@ libc_support_library(
deps = [
":__support_common",
":__support_cpp_bit",
- ":__support_sign",
":__support_cpp_type_traits",
":__support_libc_assert",
":__support_macros_attributes",
":__support_macros_properties_types",
":__support_math_extras",
+ ":__support_sign",
":__support_uint128",
],
)
@@ -964,11 +964,17 @@ libc_support_library(
libc_support_library(
name = "__support_osutil_syscall",
hdrs = ["src/__support/OSUtil/syscall.h"],
- textual_hdrs = [
- "src/__support/OSUtil/linux/syscall.h",
- "src/__support/OSUtil/linux/aarch64/syscall.h",
- "src/__support/OSUtil/linux/x86_64/syscall.h",
- ],
+ textual_hdrs = select({
+ "@platforms//os:macos": [
+ "src/__support/OSUtil/darwin/syscall.h",
+ "src/__support/OSUtil/darwin/arm/syscall.h",
+ ],
+ "//conditions:default": [
+ "src/__support/OSUtil/linux/syscall.h",
+ "src/__support/OSUtil/linux/aarch64/syscall.h",
+ "src/__support/OSUtil/linux/x86_64/syscall.h",
+ ],
+ }),
deps = [
":__support_common",
":__support_cpp_bit",
@@ -978,9 +984,10 @@ libc_support_library(
libc_support_library(
name = "__support_osutil_io",
hdrs = ["src/__support/OSUtil/io.h"],
- textual_hdrs = [
- "src/__support/OSUtil/linux/io.h",
- ],
+ textual_hdrs = select({
+ "@platforms//os:macos": ["src/__support/OSUtil/darwin/io.h"],
+ "//conditions:default": ["src/__support/OSUtil/linux/io.h"],
+ }),
deps = [
":__support_common",
":__support_cpp_string_view",
@@ -992,10 +999,15 @@ libc_support_library(
libc_support_library(
name = "__support_osutil_quick_exit",
hdrs = ["src/__support/OSUtil/quick_exit.h"],
- textual_hdrs = [
- "src/__support/OSUtil/linux/quick_exit.h",
- #TODO: add support for GPU quick_exit (isn't just in a header.)
- ],
+ textual_hdrs = select({
+ "@platforms//os:macos": [
+ "src/__support/OSUtil/darwin/quick_exit.h",
+ ],
+ "//conditions:default": [
+ "src/__support/OSUtil/linux/quick_exit.h",
+ #TODO: add support for GPU quick_exit (isn't just in a header.)
+ ],
+ }),
deps = [
":__support_osutil_syscall",
],
@@ -1927,7 +1939,12 @@ libc_math_function(name = "copysignf")
libc_math_function(name = "copysignl")
-libc_math_function(name = "copysignf128")
+libc_math_function(
+ name = "copysignf128",
+ additional_deps = [
+ ":llvm_libc_types_float128",
+ ],
+)
libc_math_function(name = "ilogb")
|
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.
This patch LGTM, I will warn you that there hasn't been much work on the MacOS build (bazel or cmake) recently so there may be some broken pieces. Feel free to send issues my way, but also we could absolutely use your expertise in bringing it online.
good to know thanks! I'm not sure how much more I will try to do, originally I just set out to do a |
e46f6de
to
bc0124a
Compare
rebased and pushed some more changes so now nothing fails to build on macOS (but many things are just skipped) |
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.
LGTM modulo a few comments. I'd need to check that this is compatible with downstream before landing this change.
This isn't enough to get everything in libc working, but I started down this path and these were the first required fixes. I might get back to more changes later.
bc0124a
to
0d56e88
Compare
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.
Downstream is happy, LGTM
With these changes you can now
bazel build @llvm-project//...
on macOS, and the targets in libc that don't yet support macOS (or non-linux) are ignored