Skip to content

Commit 1b2e63a

Browse files
authored
Merge pull request #66 from dtolnay/compat
Set more precise compatibility for all C++ libraries
2 parents a0165e1 + d84e027 commit 1b2e63a

File tree

6 files changed

+93
-14
lines changed

6 files changed

+93
-14
lines changed

BUCK

Lines changed: 40 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

defs.bzl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,35 @@ def rust_bootstrap_buildscript_run(**kwargs):
131131

132132
def cxx_bootstrap_library(
133133
name,
134-
compatible_with = None,
135134
deps = [],
135+
target_compatible_with = [],
136136
visibility = None,
137137
**kwargs):
138138
extra_deps = ["toolchains//cxx:stdlib"]
139139

140+
target_compatible_with = [
141+
select({
142+
"DEFAULT": "prelude//:none",
143+
} | {
144+
constraint: constraint
145+
for constraint in disjunction.split(" || ")
146+
})
147+
for disjunction in target_compatible_with
148+
]
149+
140150
native.cxx_library(
141151
name = "{}-compile".format(name),
142-
compatible_with = compatible_with,
143152
deps = deps + extra_deps,
144153
preferred_linkage = "static",
154+
target_compatible_with = target_compatible_with,
145155
**kwargs
146156
)
147157

148158
transition_alias(
149159
name = name,
150160
actual = ":{}-compile".format(name),
151-
compatible_with = compatible_with,
152161
incoming_transition = "toolchains//cxx:prune_cxx_configuration",
162+
target_compatible_with = target_compatible_with,
153163
visibility = visibility,
154164
)
155165

fixups/blake3/fixups.toml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ srcs = [
1616
]
1717
compiler_flags = ["-mavx512f", "-mavx512vl"]
1818
headers = ["c/*.h"]
19-
compatible_with = [
20-
"prelude//os/constraints:linux",
21-
"prelude//os/constraints:macos",
19+
target_compatible_with = [
20+
"prelude//cpu/constraints:x86_64",
21+
"prelude//os/constraints:linux || prelude//os/constraints:macos",
2222
]
2323

2424
[['cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "gnu"))'.cxx_library]]
@@ -34,7 +34,10 @@ srcs = [
3434
]
3535
compiler_flags = ["-mavx512f", "-mavx512vl"]
3636
headers = ["c/*.h"]
37-
compatible_with = ["prelude//os/constraints:windows"]
37+
target_compatible_with = [
38+
"prelude//cpu/constraints:x86_64",
39+
"prelude//os/constraints:windows",
40+
]
3841

3942
[['cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"))'.cxx_library]]
4043
name = "simd_x86_windows_msvc"
@@ -48,7 +51,10 @@ srcs = [
4851
"c/blake3_avx512_x86-64_windows_msvc.asm",
4952
]
5053
headers = ["c/*.h"]
51-
compatible_with = ["prelude//os/constraints:windows"]
54+
target_compatible_with = [
55+
"prelude//cpu/constraints:x86_64",
56+
"prelude//os/constraints:windows",
57+
]
5258

5359
['cfg(any(target_arch = "aarch64", target_arch = "arm"))']
5460
cfgs = ["blake3_neon"]
@@ -57,3 +63,6 @@ cfgs = ["blake3_neon"]
5763
name = "simd_neon-aarch64"
5864
srcs = ["c/blake3_neon.c"]
5965
headers = ["c/*.h"]
66+
target_compatible_with = [
67+
"prelude//cpu/constraints:arm64",
68+
]

fixups/psm/fixups.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ name = "psm_s-linux-x86_64"
77
srcs = ["src/arch/x86_64.s"]
88
compiler_flags = ["-xassembler-with-cpp"]
99
headers = ["src/arch/psm.h"]
10+
target_compatible_with = [
11+
"prelude//cpu/constraints:x86_64",
12+
"prelude//os/constraints:linux",
13+
]
1014

1115
['cfg(all(target_arch = "aarch64", target_os = "linux"))']
1216
cfgs = ["asm", "switchable_stack"]
@@ -15,6 +19,10 @@ name = "psm_s-linux-aarch64"
1519
srcs = ["src/arch/aarch_aapcs64.s"]
1620
compiler_flags = ["-xassembler-with-cpp"]
1721
headers = ["src/arch/psm.h"]
22+
target_compatible_with = [
23+
"prelude//cpu/constraints:arm64",
24+
"prelude//os/constraints:linux",
25+
]
1826

1927
['cfg(all(target_arch = "x86_64", target_os = "macos"))']
2028
cfgs = ["asm", "switchable_stack"]
@@ -24,6 +32,10 @@ srcs = ["src/arch/x86_64.s"]
2432
compiler_flags = ["-xassembler-with-cpp"]
2533
preprocessor_flags = ["-DCFG_TARGET_OS_macos"]
2634
headers = ["src/arch/psm.h"]
35+
target_compatible_with = [
36+
"prelude//cpu/constraints:x86_64",
37+
"prelude//os/constraints:macos",
38+
]
2739

2840
['cfg(all(target_arch = "aarch64", target_os = "macos"))']
2941
cfgs = ["asm", "switchable_stack"]
@@ -33,13 +45,21 @@ srcs = ["src/arch/aarch_aapcs64.s"]
3345
compiler_flags = ["-xassembler-with-cpp"]
3446
preprocessor_flags = ["-DCFG_TARGET_OS_macos"]
3547
headers = ["src/arch/psm.h"]
48+
target_compatible_with = [
49+
"prelude//cpu/constraints:arm64",
50+
"prelude//os/constraints:macos",
51+
]
3652

3753
['cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"))']
3854
cfgs = ["asm"]
3955
[['cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"))'.cxx_library]]
4056
name = "psm_s-windows-x86_64-msvc"
4157
srcs = ["src/arch/x86_64_msvc.asm"]
4258
headers = ["src/arch/psm.h"]
59+
target_compatible_with = [
60+
"prelude//cpu/constraints:x86_64",
61+
"prelude//os/constraints:windows",
62+
]
4363

4464
['cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "gnu"))']
4565
cfgs = ["asm"]
@@ -48,3 +68,7 @@ name = "psm_s-windows-x86_64-gnu"
4868
srcs = ["src/arch/x86_64_windows_gnu.s"]
4969
compiler_flags = ["-xassembler-with-cpp"]
5070
headers = ["src/arch/psm.h"]
71+
target_compatible_with = [
72+
"prelude//cpu/constraints:x86_64",
73+
"prelude//os/constraints:windows",
74+
]

fixups/stacker/fixups.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ buildscript.run = false
44
name = "windows"
55
srcs = ["src/arch/windows.c"]
66
compiler_flags = ["-DWINDOWS"]
7+
target_compatible_with = ["prelude//os/constraints:windows"]

fixups/winapi-x86_64-pc-windows-gnu/fixups.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ buildscript.run = false
33
[['cfg(target_os = "windows")'.prebuilt_cxx_library]]
44
name = "extra_libraries"
55
static_libs = ["lib/libwinapi_ole32.a", "lib/libwinapi_shell32.a"]
6+
target_compatible_with = ["prelude//os/constraints:windows"]

0 commit comments

Comments
 (0)