Skip to content

Commit

Permalink
Only build the c++20 test when the default toolchain is being used
Browse files Browse the repository at this point in the history
  • Loading branch information
jkurland-roku committed Sep 6, 2024
1 parent 49aa18e commit 659db85
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 55 deletions.
6 changes: 6 additions & 0 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,11 @@ cc_test(
size = "small",
srcs = ["test_cxx_standard_main.cc"],
args = ["202002"],

# Since some platforms require special toolchains (e.g. llvm 13.0.0) this
# target won't build on those platforms unless we create a new toolchain per
# platform with c++20. So instead just only run this test on platforms that
# can use the default toolchain
tags = ["manual"],
deps = [":test_cxx_standard_lib_transitioned"],
)
30 changes: 0 additions & 30 deletions tests/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ llvm.toolchain(
"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"],
"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"],
},
cxx_standard = {"": "c++17"},
)
llvm.extra_target_compatible_with(
name = "llvm_toolchain_with_urls",
constraints = ["@//:cxx17"],
)
use_repo(llvm, "llvm_toolchain_with_urls")

Expand All @@ -126,11 +121,6 @@ use_repo(llvm, "llvm_toolchain_with_urls")
llvm.toolchain(
name = "llvm_toolchain_13_0_0",
llvm_version = "13.0.0",
cxx_standard = {"": "c++17"},
)
llvm.extra_target_compatible_with(
name = "llvm_toolchain_13_0_0",
constraints = ["@//:cxx17"],
)
use_repo(llvm, "llvm_toolchain_13_0_0")

Expand All @@ -139,11 +129,6 @@ llvm.toolchain(
name = "llvm_toolchain_with_absolute_paths",
absolute_paths = True,
llvm_versions = LLVM_VERSIONS,
cxx_standard = {"": "c++17"},
)
llvm.extra_target_compatible_with(
name = "llvm_toolchain_with_absolute_paths",
constraints = ["@//:cxx17"],
)
# We can share the downloaded LLVM distribution with the first configuration.
llvm.toolchain_root(
Expand All @@ -156,11 +141,6 @@ use_repo(llvm, "llvm_toolchain_with_absolute_paths")
llvm.toolchain(
name = "llvm_toolchain_with_system_llvm",
llvm_versions = LLVM_VERSIONS,
cxx_standard = {"": "c++17"},
)
llvm.extra_target_compatible_with(
name = "llvm_toolchain_with_system_llvm",
constraints = ["@//:cxx17"],
)
# For this toolchain to work, the LLVM distribution archive would need to be unpacked here.
llvm.toolchain_root(
Expand All @@ -173,11 +153,6 @@ use_repo(llvm, "llvm_toolchain_with_system_llvm")
llvm.toolchain(
name = "llvm_toolchain_with_sysroot",
llvm_versions = LLVM_VERSIONS,
cxx_standard = {"": "c++17"},
)
llvm.extra_target_compatible_with(
name = "llvm_toolchain_with_sysroot",
constraints = ["@//:cxx17"],
)
# We can share the downloaded LLVM distribution with the first configuration.
llvm.toolchain_root(
Expand All @@ -202,10 +177,5 @@ llvm.toolchain(
# distribution = "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz",
exec_os = "linux",
exec_arch = "amd64",
cxx_standard = {"": "c++17"},
)
llvm.extra_target_compatible_with(
name = "llvm_toolchain_linux_exec",
constraints = ["@//:cxx17"],
)
use_repo(llvm, "llvm_toolchain_linux_exec")
24 changes: 0 additions & 24 deletions tests/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ llvm_toolchain(
# TODO(siddharthab): Add test.
llvm_toolchain(
name = "llvm_toolchain_with_urls",
cxx_standard = {"": "c++17"},
extra_target_compatible_with = {
"": ["@//:cxx17"],
},
llvm_versions = LLVM_VERSIONS,
sha256 = {
"": "38bc7f5563642e73e69ac5626724e206d6d539fbef653541b34cae0ba9c3f036",
Expand All @@ -85,10 +81,6 @@ llvm_toolchain(
# image base-devel as of the time of this writing (23 May 2022).
llvm_toolchain(
name = "llvm_toolchain_13_0_0",
cxx_standard = {"": "c++17"},
extra_target_compatible_with = {
"": ["@//:cxx17"],
},
llvm_version = "13.0.0",
)

Expand All @@ -104,10 +96,6 @@ llvm_register_toolchains_cxx20()
llvm_toolchain(
name = "llvm_toolchain_with_absolute_paths",
absolute_paths = True,
cxx_standard = {"": "c++17"},
extra_target_compatible_with = {
"": ["@//:cxx17"],
},
llvm_versions = LLVM_VERSIONS,
# We can share the downloaded LLVM distribution with the first configuration.
toolchain_roots = {
Expand All @@ -118,10 +106,6 @@ llvm_toolchain(
## Toolchain example with system LLVM; tested in GitHub CI.
llvm_toolchain(
name = "llvm_toolchain_with_system_llvm",
cxx_standard = {"": "c++17"},
extra_target_compatible_with = {
"": ["@//:cxx17"],
},
llvm_versions = LLVM_VERSIONS,
# For this toolchain to work, the LLVM distribution archive would need to be unpacked here.
toolchain_roots = {"": "/opt/llvm-16"},
Expand All @@ -145,10 +129,6 @@ filegroup(

llvm_toolchain(
name = "llvm_toolchain_with_sysroot",
cxx_standard = {"": "c++17"},
extra_target_compatible_with = {
"": ["@//:cxx17"],
},
llvm_versions = LLVM_VERSIONS,
sysroot = {
"linux-x86_64": "@org_chromium_sysroot_linux_x64//:sysroot",
Expand All @@ -165,14 +145,10 @@ bazel_skylib_workspace()

llvm_toolchain(
name = "llvm_toolchain_linux_exec",
cxx_standard = {"": "c++17"},
exec_arch = "amd64",
# Option 2:
# distribution = "clang+llvm-17.0.6-x86_64-linux-gnu-ubuntu-22.04.tar.xz",
exec_os = "linux",
extra_target_compatible_with = {
"": ["@//:cxx17"],
},
llvm_version = "17.0.6",
# Option 1:
sha256 = {"": "884ee67d647d77e58740c1e645649e29ae9e8a6fe87c1376be0f3a30f3cc9ab3"},
Expand Down
12 changes: 11 additions & 1 deletion tests/scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,18 @@ test_args=(
"--linkopt=-Wl,-t"
)

targets=(
"//:all"
)
# :test_cxx_standard_is_20 builds with a version of the default toolchain, if
# we're trying to build with a different toolchain then it's likely the default
# toolchain won't work so :test_cxx_standard_is_20 won't build.
if [[ -z ${toolchain_name} ]]; then
targets+=("//:test_cxx_standard_is_20")
fi

"${bazel}" ${TEST_MIGRATION:+"--strict"} --bazelrc=/dev/null test \
"${common_test_args[@]}" "${test_args[@]}" //:all
"${common_test_args[@]}" "${test_args[@]}" "${targets[@]}"

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

0 comments on commit 659db85

Please sign in to comment.