Skip to content

Commit 8fe5e8e

Browse files
committed
Add c++17 constraint to other toolchains which get registered in different tests, add host_platform repo in non bzlmod tests
1 parent 3e8dccb commit 8fe5e8e

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

tests/MODULE.bazel

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ llvm.toolchain(
111111
"darwin-aarch64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang+llvm-15.0.7-arm64-apple-darwin22.0.tar.xz"],
112112
"darwin-x86_64": ["https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang+llvm-15.0.7-x86_64-apple-darwin21.0.tar.xz"],
113113
},
114+
cxx_standard = {"": "c++17"},
115+
)
116+
llvm.extra_target_compatible_with(
117+
name = "llvm_toolchain_with_urls",
118+
constraints = ["@//:cxx17"],
114119
)
115120
use_repo(llvm, "llvm_toolchain_with_urls")
116121

@@ -121,6 +126,11 @@ use_repo(llvm, "llvm_toolchain_with_urls")
121126
llvm.toolchain(
122127
name = "llvm_toolchain_13_0_0",
123128
llvm_version = "13.0.0",
129+
cxx_standard = {"": "c++17"},
130+
)
131+
llvm.extra_target_compatible_with(
132+
name = "llvm_toolchain_13_0_0",
133+
constraints = ["@//:cxx17"],
124134
)
125135
use_repo(llvm, "llvm_toolchain_13_0_0")
126136

@@ -129,6 +139,11 @@ llvm.toolchain(
129139
name = "llvm_toolchain_with_absolute_paths",
130140
absolute_paths = True,
131141
llvm_versions = LLVM_VERSIONS,
142+
cxx_standard = {"": "c++17"},
143+
)
144+
llvm.extra_target_compatible_with(
145+
name = "llvm_toolchain_with_absolute_paths",
146+
constraints = ["@//:cxx17"],
132147
)
133148
# We can share the downloaded LLVM distribution with the first configuration.
134149
llvm.toolchain_root(
@@ -141,6 +156,11 @@ use_repo(llvm, "llvm_toolchain_with_absolute_paths")
141156
llvm.toolchain(
142157
name = "llvm_toolchain_with_system_llvm",
143158
llvm_versions = LLVM_VERSIONS,
159+
cxx_standard = {"": "c++17"},
160+
)
161+
llvm.extra_target_compatible_with(
162+
name = "llvm_toolchain_with_system_llvm",
163+
constraints = ["@//:cxx17"],
144164
)
145165
# For this toolchain to work, the LLVM distribution archive would need to be unpacked here.
146166
llvm.toolchain_root(
@@ -153,6 +173,11 @@ use_repo(llvm, "llvm_toolchain_with_system_llvm")
153173
llvm.toolchain(
154174
name = "llvm_toolchain_with_sysroot",
155175
llvm_versions = LLVM_VERSIONS,
176+
cxx_standard = {"": "c++17"},
177+
)
178+
llvm.extra_target_compatible_with(
179+
name = "llvm_toolchain_with_sysroot",
180+
constraints = ["@//:cxx17"],
156181
)
157182
# We can share the downloaded LLVM distribution with the first configuration.
158183
llvm.toolchain_root(
@@ -177,5 +202,10 @@ llvm.toolchain(
177202
# distribution = "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz",
178203
exec_os = "linux",
179204
exec_arch = "amd64",
205+
cxx_standard = {"": "c++17"},
206+
)
207+
llvm.extra_target_compatible_with(
208+
name = "llvm_toolchain_linux_exec",
209+
constraints = ["@//:cxx17"],
180210
)
181211
use_repo(llvm, "llvm_toolchain_linux_exec")

tests/WORKSPACE

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ llvm_toolchain(
5757
# TODO(siddharthab): Add test.
5858
llvm_toolchain(
5959
name = "llvm_toolchain_with_urls",
60+
cxx_standard = {"": "c++17"},
61+
extra_target_compatible_with = {
62+
"": ["@//:cxx17"],
63+
},
6064
llvm_versions = LLVM_VERSIONS,
6165
sha256 = {
6266
"": "38bc7f5563642e73e69ac5626724e206d6d539fbef653541b34cae0ba9c3f036",
@@ -81,6 +85,10 @@ llvm_toolchain(
8185
# image base-devel as of the time of this writing (23 May 2022).
8286
llvm_toolchain(
8387
name = "llvm_toolchain_13_0_0",
88+
cxx_standard = {"": "c++17"},
89+
extra_target_compatible_with = {
90+
"": ["@//:cxx17"],
91+
},
8492
llvm_version = "13.0.0",
8593
)
8694

@@ -96,6 +104,10 @@ llvm_register_toolchains_cxx20()
96104
llvm_toolchain(
97105
name = "llvm_toolchain_with_absolute_paths",
98106
absolute_paths = True,
107+
cxx_standard = {"": "c++17"},
108+
extra_target_compatible_with = {
109+
"": ["@//:cxx17"],
110+
},
99111
llvm_versions = LLVM_VERSIONS,
100112
# We can share the downloaded LLVM distribution with the first configuration.
101113
toolchain_roots = {
@@ -106,6 +118,10 @@ llvm_toolchain(
106118
## Toolchain example with system LLVM; tested in GitHub CI.
107119
llvm_toolchain(
108120
name = "llvm_toolchain_with_system_llvm",
121+
cxx_standard = {"": "c++17"},
122+
extra_target_compatible_with = {
123+
"": ["@//:cxx17"],
124+
},
109125
llvm_versions = LLVM_VERSIONS,
110126
# For this toolchain to work, the LLVM distribution archive would need to be unpacked here.
111127
toolchain_roots = {"": "/opt/llvm-16"},
@@ -129,6 +145,10 @@ filegroup(
129145

130146
llvm_toolchain(
131147
name = "llvm_toolchain_with_sysroot",
148+
cxx_standard = {"": "c++17"},
149+
extra_target_compatible_with = {
150+
"": ["@//:cxx17"],
151+
},
132152
llvm_versions = LLVM_VERSIONS,
133153
sysroot = {
134154
"linux-x86_64": "@org_chromium_sysroot_linux_x64//:sysroot",
@@ -145,10 +165,14 @@ bazel_skylib_workspace()
145165

146166
llvm_toolchain(
147167
name = "llvm_toolchain_linux_exec",
168+
cxx_standard = {"": "c++17"},
148169
exec_arch = "amd64",
149170
# Option 2:
150171
# distribution = "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz",
151172
exec_os = "linux",
173+
extra_target_compatible_with = {
174+
"": ["@//:cxx17"],
175+
},
152176
llvm_version = "17.0.6",
153177
# Option 1:
154178
sha256 = {"": "884ee67d647d77e58740c1e645649e29ae9e8a6fe87c1376be0f3a30f3cc9ab3"},
@@ -247,3 +271,16 @@ http_archive(
247271
"https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz",
248272
],
249273
)
274+
275+
http_archive(
276+
name = "platforms",
277+
sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee",
278+
urls = [
279+
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz",
280+
"https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz",
281+
],
282+
)
283+
284+
load("@platforms//host:extension.bzl", "host_platform_repo")
285+
286+
host_platform_repo(name = "host_platform")

0 commit comments

Comments
 (0)