From 34b8839a1a9f00b5a1e7dfddc06740b73be3083a Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sat, 29 Nov 2025 11:02:49 +0100 Subject: [PATCH 1/2] Bump Bazel to v7.7.1 Signed-off-by: Matthieu MOREL --- .bazelversion | 2 +- bazel/wasm.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bazelversion b/.bazelversion index f22d756da..5942a0d3a 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.5.0 +7.7.1 diff --git a/bazel/wasm.bzl b/bazel/wasm.bzl index 192823047..ead788115 100644 --- a/bazel/wasm.bzl +++ b/bazel/wasm.bzl @@ -64,7 +64,7 @@ def _wasm_attrs(transition): "binary": attr.label(mandatory = True, cfg = transition), "signing_key": attr.label_list(allow_files = True), "_wasmsign_tool": attr.label(default = "//bazel/cargo/wasmsign/remote:wasmsign__wasmsign", executable = True, cfg = "exec"), - "_whitelist_function_transition": attr.label(default = "@bazel_tools//tools/whitelists/function_transition_whitelist"), + "_allowlist_function_transition": attr.label(default = "@bazel_tools//tools/allowlists/function_transition_allowlist"), } wasm_rust_binary_rule = rule( From e1a5f35b3cd82c3c6adcb0f1a72ff451a9d19baa Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sun, 14 Dec 2025 12:26:22 +0100 Subject: [PATCH 2/2] Fix Bazel 7.7.1 compatibility for git shallow_since and clang-tidy using aspect_rules_lint Signed-off-by: Matthieu MOREL --- .bazelrc | 8 ++--- WORKSPACE | 5 ++++ bazel/dependencies.bzl | 7 +++++ bazel/external/bazel_clang_tidy.patch | 16 ---------- bazel/repositories.bzl | 42 ++++++++++++++++++++++----- bazel/setup_features.bzl | 21 ++++++++++++++ tools/lint/BUILD | 30 +++++++++++++++++++ tools/lint/linters.bzl | 23 +++++++++++++++ 8 files changed, 124 insertions(+), 28 deletions(-) delete mode 100644 bazel/external/bazel_clang_tidy.patch create mode 100644 bazel/setup_features.bzl create mode 100644 tools/lint/BUILD create mode 100644 tools/lint/linters.bzl diff --git a/.bazelrc b/.bazelrc index 5a0373356..2c1695ce1 100644 --- a/.bazelrc +++ b/.bazelrc @@ -57,11 +57,9 @@ build:clang-tsan --copt -fsanitize=thread build:clang-tsan --linkopt -fsanitize=thread build:clang-tsan --test_env=TSAN_OPTIONS=suppressions=bazel/tsan_suppressions.txt -# Use Clang-Tidy tool. -build:clang-tidy --config=clang -build:clang-tidy --aspects @bazel_clang_tidy//clang_tidy:clang_tidy.bzl%clang_tidy_aspect -build:clang-tidy --@bazel_clang_tidy//:clang_tidy_config=@proxy_wasm_cpp_host//:clang_tidy_config -build:clang-tidy --output_groups=report +# Use Clang-Tidy tool with hermetic LLVM toolchain via aspect_rules_lint. +build:clang-tidy --aspects //tools/lint:linters.bzl%clang_tidy +build:clang-tidy --output_groups=rules_lint_report # Use GCC compiler. build:gcc --action_env=BAZEL_COMPILER=gcc diff --git a/WORKSPACE b/WORKSPACE index dad42c2f8..0a5f45e59 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -8,6 +8,11 @@ load("@proxy_wasm_cpp_host//bazel:dependencies.bzl", "proxy_wasm_cpp_host_depend proxy_wasm_cpp_host_dependencies() +# Setup bazel_features internal repos (required for aspect_rules_lint) +load("@proxy_wasm_cpp_host//bazel:setup_features.bzl", "setup_bazel_features") + +setup_bazel_features() + load("@proxy_wasm_cpp_host//bazel:dependencies_python.bzl", "proxy_wasm_cpp_host_dependencies_python") proxy_wasm_cpp_host_dependencies_python() diff --git a/bazel/dependencies.bzl b/bazel/dependencies.bzl index 683fb9964..e41617c3d 100644 --- a/bazel/dependencies.bzl +++ b/bazel/dependencies.bzl @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@aspect_rules_lint//format:repositories.bzl", "rules_lint_dependencies") +load("@bazel_lib//lib:repositories.bzl", "bazel_lib_dependencies", "bazel_lib_register_toolchains") load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") load("@envoy_toolshed//sysroot:sysroot.bzl", "setup_sysroots") load("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:crates.bzl", wasmsign_crate_repositories = "crate_repositories") @@ -54,6 +56,11 @@ def proxy_wasm_cpp_host_dependencies(): ) crate_universe_dependencies(bootstrap = True) + # Aspect dependencies for clang-tidy integration + rules_lint_dependencies() + bazel_lib_dependencies() + bazel_lib_register_toolchains() + setup_sysroots() bazel_toolchain_dependencies() llvm_toolchain( diff --git a/bazel/external/bazel_clang_tidy.patch b/bazel/external/bazel_clang_tidy.patch deleted file mode 100644 index 82711d83e..000000000 --- a/bazel/external/bazel_clang_tidy.patch +++ /dev/null @@ -1,16 +0,0 @@ -# 1. Treat .h files as C++ headers. - -diff --git a/clang_tidy/clang_tidy.bzl b/clang_tidy/clang_tidy.bzl -index 3a5ed07..5db5c6c 100644 ---- a/clang_tidy/clang_tidy.bzl -+++ b/clang_tidy/clang_tidy.bzl -@@ -16,6 +16,9 @@ def _run_tidy(ctx, exe, flags, compilation_context, infile, discriminator): - # add source to check - args.add(infile.path) - -+ # treat .h files as C++ headers -+ args.add("--extra-arg-before=-xc++") -+ - # start args passed to the compiler - args.add("--") - diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 8e6e3c88f..4879d5a09 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -48,14 +48,42 @@ def proxy_wasm_cpp_host_repositories(): urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"], ) + # aspect_rules_lint v1.12.0 for modern clang-tidy integration maybe( http_archive, - name = "bazel_clang_tidy", - sha256 = "6ed23cbff9423a30ef10becf57210a26d54fe198a211f4037d931c06f843c023", - strip_prefix = "bazel_clang_tidy-c2fe98cfec0430e78bff4169e9ca0a43123e4c99", - url = "https://github.com/erenon/bazel_clang_tidy/archive/c2fe98cfec0430e78bff4169e9ca0a43123e4c99.tar.gz", - patches = ["@proxy_wasm_cpp_host//bazel/external:bazel_clang_tidy.patch"], - patch_args = ["-p1"], + name = "aspect_rules_lint", + sha256 = "a8a63bd071a39bd5be1f99d9f258eac674673c98505f9fc5b4c76587f67278cd", + strip_prefix = "rules_lint-1.12.0", + url = "https://github.com/aspect-build/rules_lint/releases/download/v1.12.0/rules_lint-v1.12.0.tar.gz", + ) + + # bazel_lib v3.0.1 required by aspect_rules_lint v1.12.0 + maybe( + http_archive, + name = "bazel_lib", + sha256 = "8b074b1a2731d29f6b95defdca95297354dc424492caf7019cf6b9f36afba54f", + strip_prefix = "bazel-lib-3.0.1", + url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v3.0.1/bazel-lib-v3.0.1.tar.gz", + ) + + # aspect_bazel_lib alias for aspect_rules_js v2.1.2 compatibility + # aspect_rules_js expects @aspect_bazel_lib while aspect_rules_lint expects @bazel_lib + # Both repos reference the same bazel-lib v3.0.1 release to maintain consistency + maybe( + http_archive, + name = "aspect_bazel_lib", + sha256 = "8b074b1a2731d29f6b95defdca95297354dc424492caf7019cf6b9f36afba54f", + strip_prefix = "bazel-lib-3.0.1", + url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v3.0.1/bazel-lib-v3.0.1.tar.gz", + ) + + # aspect_rules_js is required by aspect_rules_lint + maybe( + http_archive, + name = "aspect_rules_js", + sha256 = "fbc34d815a0cc52183a1a26732fc0329e26774a51abbe0f26fc9fd2dab6133b4", + strip_prefix = "rules_js-2.1.2", + url = "https://github.com/aspect-build/rules_js/releases/download/v2.1.2/rules_js-v2.1.2.tar.gz", ) maybe( @@ -180,7 +208,7 @@ def proxy_wasm_cpp_host_repositories(): # 13.8.258.26 commit = "de9d0f8b56ae61896e4d2ac577fc589efb14f87d", remote = "https://chromium.googlesource.com/v8/v8", - shallow_since = "1752074621 -0400", + shallow_since = "1752074621", patches = [ "@proxy_wasm_cpp_host//bazel/external:v8.patch", ], diff --git a/bazel/setup_features.bzl b/bazel/setup_features.bzl new file mode 100644 index 000000000..2c8474335 --- /dev/null +++ b/bazel/setup_features.bzl @@ -0,0 +1,21 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Setup bazel_features internal repositories.""" + +load("@bazel_features//private:repos.bzl", "bazel_features_repos") + +def setup_bazel_features(): + """Initialize bazel_features internal repos (needed for WORKSPACE compat).""" + bazel_features_repos() diff --git a/tools/lint/BUILD b/tools/lint/BUILD new file mode 100644 index 000000000..13b2b460d --- /dev/null +++ b/tools/lint/BUILD @@ -0,0 +1,30 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("@bazel_skylib//rules:native_binary.bzl", "native_binary") + +# Make hermetic clang-tidy available as a binary for aspect_rules_lint +native_binary( + name = "clang_tidy", + src = select( + { + "@bazel_tools//src/conditions:linux_x86_64": "@llvm_toolchain_llvm//:bin/clang-tidy", + "@bazel_tools//src/conditions:linux_aarch64": "@llvm_toolchain_llvm//:bin/clang-tidy", + "@bazel_tools//src/conditions:darwin_x86_64": "@llvm_toolchain_llvm//:bin/clang-tidy", + "@bazel_tools//src/conditions:darwin_arm64": "@llvm_toolchain_llvm//:bin/clang-tidy", + }, + ), + out = "clang_tidy", + visibility = ["//visibility:public"], +) diff --git a/tools/lint/linters.bzl b/tools/lint/linters.bzl new file mode 100644 index 000000000..bb2f2ead3 --- /dev/null +++ b/tools/lint/linters.bzl @@ -0,0 +1,23 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Linter configurations for the project.""" + +load("@aspect_rules_lint//lint:clang_tidy.bzl", "lint_clang_tidy_aspect") + +# Configure clang-tidy to use the hermetic LLVM toolchain +clang_tidy = lint_clang_tidy_aspect( + binary = "@@//tools/lint:clang_tidy", + configs = ["@@//:.clang-tidy"], +)