Skip to content

Commit bc0124a

Browse files
committed
[bazel] Improve libc build on macOS
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.
1 parent f4fc959 commit bc0124a

File tree

1 file changed

+73
-13
lines changed

1 file changed

+73
-13
lines changed

utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Lines changed: 73 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ libc_support_library(
9494
libc_support_library(
9595
name = "llvm_libc_types_float128",
9696
hdrs = ["include/llvm-libc-types/float128.h"],
97+
target_compatible_with = select({
98+
"@platforms//os:linux": [],
99+
"//conditions:default": ["@platforms//:incompatible"],
100+
}),
97101
deps = [":llvm_libc_macros_float_macros"],
98102
)
99103

@@ -622,12 +626,12 @@ libc_support_library(
622626
name = "__support_fputil_basic_operations",
623627
hdrs = ["src/__support/FPUtil/BasicOperations.h"],
624628
deps = [
625-
":__support_fputil_fenv_impl",
626-
":__support_macros_optimization",
627-
":__support_uint128",
628629
":__support_common",
629630
":__support_cpp_type_traits",
631+
":__support_fputil_fenv_impl",
630632
":__support_fputil_fp_bits",
633+
":__support_macros_optimization",
634+
":__support_uint128",
631635
],
632636
)
633637

@@ -974,11 +978,17 @@ libc_support_library(
974978
libc_support_library(
975979
name = "__support_osutil_syscall",
976980
hdrs = ["src/__support/OSUtil/syscall.h"],
977-
textual_hdrs = [
978-
"src/__support/OSUtil/linux/syscall.h",
979-
"src/__support/OSUtil/linux/aarch64/syscall.h",
980-
"src/__support/OSUtil/linux/x86_64/syscall.h",
981-
],
981+
textual_hdrs = select({
982+
"@platforms//os:macos": [
983+
"src/__support/OSUtil/darwin/syscall.h",
984+
"src/__support/OSUtil/darwin/arm/syscall.h",
985+
],
986+
"//conditions:default": [
987+
"src/__support/OSUtil/linux/syscall.h",
988+
"src/__support/OSUtil/linux/aarch64/syscall.h",
989+
"src/__support/OSUtil/linux/x86_64/syscall.h",
990+
],
991+
}),
982992
deps = [
983993
":__support_common",
984994
":__support_cpp_bit",
@@ -988,9 +998,10 @@ libc_support_library(
988998
libc_support_library(
989999
name = "__support_osutil_io",
9901000
hdrs = ["src/__support/OSUtil/io.h"],
991-
textual_hdrs = [
992-
"src/__support/OSUtil/linux/io.h",
993-
],
1001+
textual_hdrs = select({
1002+
"@platforms//os:macos": ["src/__support/OSUtil/darwin/io.h"],
1003+
"//conditions:default": ["src/__support/OSUtil/linux/io.h"],
1004+
}),
9941005
deps = [
9951006
":__support_common",
9961007
":__support_cpp_string_view",
@@ -1001,8 +1012,12 @@ libc_support_library(
10011012

10021013
libc_support_library(
10031014
name = "__support_osutil_quick_exit",
1004-
hdrs = ["src/__support/OSUtil/quick_exit.h"],
10051015
srcs = ["src/__support/OSUtil/linux/quick_exit.cpp"],
1016+
hdrs = ["src/__support/OSUtil/quick_exit.h"],
1017+
target_compatible_with = select({
1018+
"@platforms//os:linux": [],
1019+
"//conditions:default": ["@platforms//:incompatible"],
1020+
}),
10061021
deps = [
10071022
":__support_osutil_syscall",
10081023
],
@@ -1021,6 +1036,10 @@ libc_support_library(
10211036
"src/__support/StringUtil/error_to_string.h",
10221037
"src/__support/StringUtil/signal_to_string.h",
10231038
],
1039+
target_compatible_with = select({
1040+
"@platforms//os:linux": [],
1041+
"//conditions:default": ["@platforms//:incompatible"],
1042+
}),
10241043
deps = [
10251044
":__support_cpp_array",
10261045
":__support_cpp_span",
@@ -1038,6 +1057,10 @@ libc_support_library(
10381057
"src/__support/threads/mutex.h",
10391058
"src/__support/threads/mutex_common.h",
10401059
],
1060+
target_compatible_with = select({
1061+
"@platforms//os:linux": [],
1062+
"//conditions:default": ["@platforms//:incompatible"],
1063+
}),
10411064
textual_hdrs = [
10421065
"src/__support/threads/linux/mutex.h",
10431066
"src/__support/threads/linux/futex_word.h",
@@ -1934,7 +1957,12 @@ libc_math_function(name = "copysignf")
19341957

19351958
libc_math_function(name = "copysignl")
19361959

1937-
libc_math_function(name = "copysignf128")
1960+
libc_math_function(
1961+
name = "copysignf128",
1962+
additional_deps = [
1963+
":llvm_libc_types_float128",
1964+
],
1965+
)
19381966

19391967
libc_math_function(name = "ilogb")
19401968

@@ -2600,6 +2628,10 @@ libc_function(
26002628
name = "open",
26012629
srcs = ["src/fcntl/linux/open.cpp"],
26022630
hdrs = ["src/fcntl/open.h"],
2631+
target_compatible_with = select({
2632+
"@platforms//os:linux": [],
2633+
"//conditions:default": ["@platforms//:incompatible"],
2634+
}),
26032635
deps = [
26042636
":__support_common",
26052637
":__support_osutil_syscall",
@@ -2611,6 +2643,10 @@ libc_function(
26112643
name = "openat",
26122644
srcs = ["src/fcntl/linux/openat.cpp"],
26132645
hdrs = ["src/fcntl/openat.h"],
2646+
target_compatible_with = select({
2647+
"@platforms//os:linux": [],
2648+
"//conditions:default": ["@platforms//:incompatible"],
2649+
}),
26142650
deps = [
26152651
":__support_common",
26162652
":__support_osutil_syscall",
@@ -2690,6 +2726,10 @@ libc_function(
26902726
name = "dup3",
26912727
srcs = ["src/unistd/linux/dup3.cpp"],
26922728
hdrs = ["src/unistd/dup3.h"],
2729+
target_compatible_with = select({
2730+
"@platforms//os:linux": [],
2731+
"//conditions:default": ["@platforms//:incompatible"],
2732+
}),
26932733
deps = [
26942734
":__support_common",
26952735
":__support_osutil_syscall",
@@ -2859,6 +2899,10 @@ libc_function(
28592899
name = "pread",
28602900
srcs = ["src/unistd/linux/pread.cpp"],
28612901
hdrs = ["src/unistd/pread.h"],
2902+
target_compatible_with = select({
2903+
"@platforms//os:linux": [],
2904+
"//conditions:default": ["@platforms//:incompatible"],
2905+
}),
28622906
deps = [
28632907
":__support_common",
28642908
":__support_osutil_syscall",
@@ -2870,6 +2914,10 @@ libc_function(
28702914
name = "pwrite",
28712915
srcs = ["src/unistd/linux/pwrite.cpp"],
28722916
hdrs = ["src/unistd/pwrite.h"],
2917+
target_compatible_with = select({
2918+
"@platforms//os:linux": [],
2919+
"//conditions:default": ["@platforms//:incompatible"],
2920+
}),
28732921
deps = [
28742922
":__support_common",
28752923
":__support_osutil_syscall",
@@ -3272,6 +3320,10 @@ libc_function(
32723320
name = "rename",
32733321
srcs = ["src/stdio/linux/rename.cpp"],
32743322
hdrs = ["src/stdio/rename.h"],
3323+
target_compatible_with = select({
3324+
"@platforms//os:linux": [],
3325+
"//conditions:default": ["@platforms//:incompatible"],
3326+
}),
32753327
deps = [
32763328
":__support_common",
32773329
":__support_osutil_syscall",
@@ -3310,6 +3362,10 @@ libc_function(
33103362
name = "epoll_wait",
33113363
srcs = ["src/sys/epoll/linux/epoll_wait.cpp"],
33123364
hdrs = ["src/sys/epoll/epoll_wait.h"],
3365+
target_compatible_with = select({
3366+
"@platforms//os:linux": [],
3367+
"//conditions:default": ["@platforms//:incompatible"],
3368+
}),
33133369
weak = True,
33143370
deps = [
33153371
":__support_osutil_syscall",
@@ -3321,6 +3377,10 @@ libc_function(
33213377
name = "epoll_pwait",
33223378
srcs = ["src/sys/epoll/linux/epoll_pwait.cpp"],
33233379
hdrs = ["src/sys/epoll/epoll_pwait.h"],
3380+
target_compatible_with = select({
3381+
"@platforms//os:linux": [],
3382+
"//conditions:default": ["@platforms//:incompatible"],
3383+
}),
33243384
weak = True,
33253385
deps = [
33263386
":__support_osutil_syscall",

0 commit comments

Comments
 (0)