From 069a43cfeefed56b784400e901deac94bf54dcb6 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Thu, 31 Oct 2024 10:58:05 +0100 Subject: [PATCH 1/2] Fix test module for Bazel 8 Clean up canonical label usages and fix runfiles references for `--nolegacy_external_runfiles`. --- .bazelignore | 1 + .github/workflows/tests.yml | 2 +- tests/.bazelrc | 1 + tests/BUILD.bazel | 4 ++-- tests/MODULE.bazel | 19 ++++++++++++++++++- tests/WORKSPACE.bzlmod | 14 -------------- tests/file_dependency_test.sh | 4 ++-- 7 files changed, 25 insertions(+), 20 deletions(-) create mode 100644 .bazelignore diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 00000000..2b29f276 --- /dev/null +++ b/.bazelignore @@ -0,0 +1 @@ +tests diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1a7f81bb..5a85be68 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,7 +28,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, ubuntu-latest] - bazel_version: [7.0.0, latest] # Minimum supported Bazel version is 7.0.0. + bazel_version: [7.0.0, latest, last_rc] # Minimum supported Bazel version is 7.0.0. bzlmod: [true, false] runs-on: ${{ matrix.os }} steps: diff --git a/tests/.bazelrc b/tests/.bazelrc index cbbcfb85..e3a15497 100644 --- a/tests/.bazelrc +++ b/tests/.bazelrc @@ -1,2 +1,3 @@ common --incompatible_disallow_empty_glob +common --nolegacy_external_runfiles build --features=layering_check diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 02ab2032..1c953b21 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -120,7 +120,7 @@ sh_test( name = "file_dependency_test", srcs = ["file_dependency_test.sh"], args = [ - "$(execpath @llvm_toolchain_llvm//:bin/clang-format)", + "$(rootpath @llvm_toolchain_llvm//:bin/clang-format)", "$(rootpaths @llvm_toolchain_llvm//:lib)", ], data = [ @@ -136,7 +136,7 @@ toolchain( "@platforms//cpu:arm64", "@platforms//os:macos", ], - toolchain = "@@rules_foreign_cc~~tools~ninja_1.11.1_mac//:ninja_tool", + toolchain = "@ninja_mac//:ninja_tool", toolchain_type = "@rules_foreign_cc//toolchains:ninja_toolchain", ) diff --git a/tests/MODULE.bazel b/tests/MODULE.bazel index 5d4bfa8c..b37c838f 100644 --- a/tests/MODULE.bazel +++ b/tests/MODULE.bazel @@ -29,6 +29,8 @@ bazel_dep(name = "rules_foreign_cc", version = "0.12.0") bazel_dep(name = "abseil-cpp", version = "20240722.0", repo_name = "com_google_absl") # As a workaround for https://github.com/bazelbuild/rules_foreign_cc/issues/1018. +rules_foreign_cc_tools = use_extension("@rules_foreign_cc//foreign_cc:extensions.bzl", "tools") +use_repo(rules_foreign_cc_tools, ninja_mac = "ninja_1.12.1_mac") register_toolchains( "//:ninja_mac_arm64_toolchain", ) @@ -162,7 +164,7 @@ llvm.toolchain_root( llvm.sysroot( name = "llvm_toolchain_with_sysroot", targets = ["linux-x86_64"], - label = "@@org_chromium_sysroot_linux_x64//:sysroot", + label = "@org_chromium_sysroot_linux_x64//:sysroot", ) use_repo(llvm, "llvm_toolchain_with_sysroot") @@ -216,3 +218,18 @@ wasi_sdk_sysroots(name = "wasi_sdk_sysroots") libclang_rt_wasm32 = use_repo_rule("//wasm:wasi_sdk.bzl", "libclang_rt_wasm32") libclang_rt_wasm32(name = "libclang_rt_wasm32") + +http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +# This sysroot is used by github.com/vsco/bazel-toolchains. +http_archive( + name = "org_chromium_sysroot_linux_x64", + build_file_content = """ +filegroup( + name = "sysroot", + srcs = glob(["*/**"]), + visibility = ["//visibility:public"], +) +""", + sha256 = "84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3", + urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_amd64_sysroot.tar.xz"], +) diff --git a/tests/WORKSPACE.bzlmod b/tests/WORKSPACE.bzlmod index 7e848f7c..7aae8c4f 100644 --- a/tests/WORKSPACE.bzlmod +++ b/tests/WORKSPACE.bzlmod @@ -2,20 +2,6 @@ workspace(name = "toolchains_llvm_tests") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -# This sysroot is used by github.com/vsco/bazel-toolchains. -http_archive( - name = "org_chromium_sysroot_linux_x64", - build_file_content = """ -filegroup( - name = "sysroot", - srcs = glob(["*/**"]), - visibility = ["//visibility:public"], -) -""", - sha256 = "84656a6df544ecef62169cfe3ab6e41bb4346a62d3ba2a045dc5a0a2ecea94a3", - urls = ["https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/2202c161310ffde63729f29d27fe7bb24a0bc540/debian_stretch_amd64_sysroot.tar.xz"], -) - # Well known repos; present here only for testing. http_archive( diff --git a/tests/file_dependency_test.sh b/tests/file_dependency_test.sh index 37f2f1df..bf60e2bd 100755 --- a/tests/file_dependency_test.sh +++ b/tests/file_dependency_test.sh @@ -21,10 +21,10 @@ fail() { clang_format_path=$1 libcpp_path=$2 -[[ -e ${clang_format_path} ]] || fail "bin/clang-format not found" +[[ -e ${clang_format_path} ]] || fail "bin/clang-format not found at ${clang_format_path}" [[ -e ${libcpp_path} ]] || compgen -G "${libcpp_path}" >/dev/null || - fail "libc++.a not found" + fail "libc++.a not found at ${libcpp_path}" echo "SUCCESS!" From 6e06b8723bce29e54b36f14d16bf7a6b15220f8f Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Thu, 31 Oct 2024 11:10:24 +0100 Subject: [PATCH 2/2] Update tests.yml --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5a85be68..51bd2df8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,7 +28,8 @@ jobs: fail-fast: false matrix: os: [macos-latest, ubuntu-latest] - bazel_version: [7.0.0, latest, last_rc] # Minimum supported Bazel version is 7.0.0. + # TODO: Test with Bazel 8 after https://github.com/bazelbuild/bazel/pull/24154 has been released. + bazel_version: [7.0.0, latest] # Minimum supported Bazel version is 7.0.0. bzlmod: [true, false] runs-on: ${{ matrix.os }} steps: