Skip to content

Commit cee2d4f

Browse files
jkurland-rokufmeum
authored andcommitted
Only build the c++20 test when the default toolchain is being used
1 parent 49aa18e commit cee2d4f

File tree

4 files changed

+16
-55
lines changed

4 files changed

+16
-55
lines changed

tests/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,11 @@ cc_test(
192192
size = "small",
193193
srcs = ["test_cxx_standard_main.cc"],
194194
args = ["202002"],
195+
196+
# Since some platforms require special toolchains (e.g. llvm 13.0.0) this
197+
# target won't build on those platforms unless we create a new toolchain per
198+
# platform with c++20. So instead just only run this test on platforms that
199+
# can use the default toolchain
200+
tags = ["manual"],
195201
deps = [":test_cxx_standard_lib_transitioned"],
196202
)

tests/MODULE.bazel

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@ 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"],
119114
)
120115
use_repo(llvm, "llvm_toolchain_with_urls")
121116

@@ -126,11 +121,6 @@ use_repo(llvm, "llvm_toolchain_with_urls")
126121
llvm.toolchain(
127122
name = "llvm_toolchain_13_0_0",
128123
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"],
134124
)
135125
use_repo(llvm, "llvm_toolchain_13_0_0")
136126

@@ -139,11 +129,6 @@ llvm.toolchain(
139129
name = "llvm_toolchain_with_absolute_paths",
140130
absolute_paths = True,
141131
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"],
147132
)
148133
# We can share the downloaded LLVM distribution with the first configuration.
149134
llvm.toolchain_root(
@@ -156,11 +141,6 @@ use_repo(llvm, "llvm_toolchain_with_absolute_paths")
156141
llvm.toolchain(
157142
name = "llvm_toolchain_with_system_llvm",
158143
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"],
164144
)
165145
# For this toolchain to work, the LLVM distribution archive would need to be unpacked here.
166146
llvm.toolchain_root(
@@ -173,11 +153,6 @@ use_repo(llvm, "llvm_toolchain_with_system_llvm")
173153
llvm.toolchain(
174154
name = "llvm_toolchain_with_sysroot",
175155
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"],
181156
)
182157
# We can share the downloaded LLVM distribution with the first configuration.
183158
llvm.toolchain_root(
@@ -202,10 +177,5 @@ llvm.toolchain(
202177
# distribution = "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz",
203178
exec_os = "linux",
204179
exec_arch = "amd64",
205-
cxx_standard = {"": "c++17"},
206-
)
207-
llvm.extra_target_compatible_with(
208-
name = "llvm_toolchain_linux_exec",
209-
constraints = ["@//:cxx17"],
210180
)
211181
use_repo(llvm, "llvm_toolchain_linux_exec")

tests/WORKSPACE

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ 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-
},
6460
llvm_versions = LLVM_VERSIONS,
6561
sha256 = {
6662
"": "38bc7f5563642e73e69ac5626724e206d6d539fbef653541b34cae0ba9c3f036",
@@ -85,10 +81,6 @@ llvm_toolchain(
8581
# image base-devel as of the time of this writing (23 May 2022).
8682
llvm_toolchain(
8783
name = "llvm_toolchain_13_0_0",
88-
cxx_standard = {"": "c++17"},
89-
extra_target_compatible_with = {
90-
"": ["@//:cxx17"],
91-
},
9284
llvm_version = "13.0.0",
9385
)
9486

@@ -104,10 +96,6 @@ llvm_register_toolchains_cxx20()
10496
llvm_toolchain(
10597
name = "llvm_toolchain_with_absolute_paths",
10698
absolute_paths = True,
107-
cxx_standard = {"": "c++17"},
108-
extra_target_compatible_with = {
109-
"": ["@//:cxx17"],
110-
},
11199
llvm_versions = LLVM_VERSIONS,
112100
# We can share the downloaded LLVM distribution with the first configuration.
113101
toolchain_roots = {
@@ -118,10 +106,6 @@ llvm_toolchain(
118106
## Toolchain example with system LLVM; tested in GitHub CI.
119107
llvm_toolchain(
120108
name = "llvm_toolchain_with_system_llvm",
121-
cxx_standard = {"": "c++17"},
122-
extra_target_compatible_with = {
123-
"": ["@//:cxx17"],
124-
},
125109
llvm_versions = LLVM_VERSIONS,
126110
# For this toolchain to work, the LLVM distribution archive would need to be unpacked here.
127111
toolchain_roots = {"": "/opt/llvm-16"},
@@ -145,10 +129,6 @@ filegroup(
145129

146130
llvm_toolchain(
147131
name = "llvm_toolchain_with_sysroot",
148-
cxx_standard = {"": "c++17"},
149-
extra_target_compatible_with = {
150-
"": ["@//:cxx17"],
151-
},
152132
llvm_versions = LLVM_VERSIONS,
153133
sysroot = {
154134
"linux-x86_64": "@org_chromium_sysroot_linux_x64//:sysroot",
@@ -165,14 +145,10 @@ bazel_skylib_workspace()
165145

166146
llvm_toolchain(
167147
name = "llvm_toolchain_linux_exec",
168-
cxx_standard = {"": "c++17"},
169148
exec_arch = "amd64",
170149
# Option 2:
171150
# distribution = "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz",
172151
exec_os = "linux",
173-
extra_target_compatible_with = {
174-
"": ["@//:cxx17"],
175-
},
176152
llvm_version = "17.0.6",
177153
# Option 1:
178154
sha256 = {"": "884ee67d647d77e58740c1e645649e29ae9e8a6fe87c1376be0f3a30f3cc9ab3"},

tests/scripts/run_tests.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,17 @@ test_args=(
4646
"--linkopt=-Wl,-t"
4747
)
4848

49+
# :test_cxx_standard_is_20 builds with a version of the default toolchain, if
50+
# we're trying to build with a different toolchain then it's likely the default
51+
# toolchain won't work so :test_cxx_standard_is_20 won't build.
52+
if [[ -z ${toolchain_name} ]]; then
53+
run_cxx20_toolchain=":test_cxx_standard_is_20"
54+
else
55+
run_cxx20_toolchain=""
56+
fi
57+
4958
"${bazel}" ${TEST_MIGRATION:+"--strict"} --bazelrc=/dev/null test \
50-
"${common_test_args[@]}" "${test_args[@]}" //:all
59+
"${common_test_args[@]}" "${test_args[@]}" //:all "${run_cxx20_toolchain}"
5160

5261
# Note that the following flags are currently known to cause issues in migration tests:
5362
# --incompatible_disallow_struct_provider_syntax # https://github.com/bazelbuild/bazel/issues/7347

0 commit comments

Comments
 (0)