From cee2d4fabfd273d14d6b1f52f004b72c347a552e Mon Sep 17 00:00:00 2001 From: Joshua Kurland Date: Fri, 30 Aug 2024 11:02:37 +0100 Subject: [PATCH] Only build the c++20 test when the default toolchain is being used --- tests/BUILD.bazel | 6 ++++++ tests/MODULE.bazel | 30 ------------------------------ tests/WORKSPACE | 24 ------------------------ tests/scripts/run_tests.sh | 11 ++++++++++- 4 files changed, 16 insertions(+), 55 deletions(-) diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index c1c9f8fe..02ab2032 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -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"], ) diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index 7eb07566..1145b32c 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -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") @@ -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") @@ -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( @@ -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( @@ -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( @@ -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") diff --git a/tests/WORKSPACE b/tests/WORKSPACE index f2a8af6f..65c8ee52 100644 --- a/tests/WORKSPACE +++ b/tests/WORKSPACE @@ -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", @@ -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", ) @@ -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 = { @@ -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"}, @@ -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", @@ -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"}, diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh index 694e5533..47e74b39 100755 --- a/tests/scripts/run_tests.sh +++ b/tests/scripts/run_tests.sh @@ -46,8 +46,17 @@ test_args=( "--linkopt=-Wl,-t" ) +# :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 + run_cxx20_toolchain=":test_cxx_standard_is_20" +else + run_cxx20_toolchain="" +fi + "${bazel}" ${TEST_MIGRATION:+"--strict"} --bazelrc=/dev/null test \ - "${common_test_args[@]}" "${test_args[@]}" //:all + "${common_test_args[@]}" "${test_args[@]}" //:all "${run_cxx20_toolchain}" # 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