From be91eb3107de5b3bf716170911e48083beb809e3 Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Tue, 9 Dec 2025 23:42:18 +0000 Subject: [PATCH 1/5] Exclude grpc_generator.cc from linting as its a vendored file Signed-off-by: Dom Del Nano (cherry picked from commit 430eb96029715d50c04b78056f237006dcd710c8) --- .arclint | 1 + 1 file changed, 1 insertion(+) diff --git a/.arclint b/.arclint index 7b87106fe80..2bb8b3b8303 100644 --- a/.arclint +++ b/.arclint @@ -34,6 +34,7 @@ "(^src/ui/src/types/schema\\.ts$)", "(^third_party/cpplint/cpplint.py$)", "(^third_party/gogoproto/gogo.proto$)", + "(^third_party/protoc-gen-grpc-web/grpc_generator.cc$)", "(c_cpp_properties.json$)", "(go\\.mod$)", "(go\\.sum$)" From 019d06e7a9c8e136f41a179c64ac834cf62744e2 Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Tue, 9 Dec 2025 21:11:24 +0000 Subject: [PATCH 2/5] Upgrade to bazel 7 Signed-off-by: Dom Del Nano --- .bazelrc | 4 +- .bazelversion | 2 +- .../unix_cc_toolchain_config.patch | 110 ++++++++++++------ bazel/pl_build_system.bzl | 3 +- bazel/repository_locations.bzl | 4 +- ...ery_ignore_non_target_and_incompatible.bzl | 5 +- 6 files changed, 87 insertions(+), 41 deletions(-) diff --git a/.bazelrc b/.bazelrc index 7ea81ad73b4..46a47381321 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,5 +1,7 @@ # Global bazelrc file, see https://docs.bazel.build/versions/master/guide.html#bazelrc. +common --noenable_bzlmod --enable_workspace + # Use strict action env to prevent leaks of env vars. build --incompatible_strict_action_env @@ -97,7 +99,7 @@ test:aarch64_sysroot --test_tag_filters=-no_libcpp,-requires_root,-requires_bpf, # Build for Clang using Libc++. build:clang --config=clang-base build:clang --//bazel:enable_libcpp -build:clang --features=libc++ --features=-libstdc++ +build:clang --features=libc++ --features=-libstdc++ --host_features=libc++ --host_features=-libstdc++ build:clang --build_tag_filters=-no_libcpp build:clang --test_tag_filters=-no_libcpp,-requires_root,-requires_bpf,-disabled test:clang --config=tmp-sandbox diff --git a/.bazelversion b/.bazelversion index f22d756da39..5942a0d3a0e 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.5.0 +7.7.1 diff --git a/bazel/cc_toolchains/unix_cc_toolchain_config.patch b/bazel/cc_toolchains/unix_cc_toolchain_config.patch index dff0b5f2d9c..37c40e47262 100644 --- a/bazel/cc_toolchains/unix_cc_toolchain_config.patch +++ b/bazel/cc_toolchains/unix_cc_toolchain_config.patch @@ -1,15 +1,16 @@ -diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl ---- a/cc_toolchain_config.bzl 2023-01-06 15:34:50.000000000 -0800 -+++ b/cc_toolchain_config.bzl 2023-01-22 15:33:16.794758043 -0800 -@@ -27,6 +27,7 @@ - "with_feature_set", - ) +diff --git a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl +index 1dd0e7a6e7..29b59c6325 100644 +--- a/cc_toolchain_config.bzl ++++ b/cc_toolchain_config.bzl +@@ -15,6 +15,7 @@ + """A Starlark cc_toolchain configuration rule""" + load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") +load(":toolchain_features.bzl", "pl_toolchain_pre_features", "PL_EXTRA_CC_CONFIG_ATTRS", "pl_toolchain_post_features", "pl_action_configs") - - def layering_check_features(compiler): - if compiler != "clang": -@@ -147,7 +148,7 @@ + load( + "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", + "action_config", +@@ -228,7 +229,7 @@ def _impl(ctx): tool_path(name = name, path = path) for name, path in ctx.attr.tool_paths.items() ] @@ -18,7 +19,7 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl llvm_cov_action = action_config( action_name = ACTION_NAMES.llvm_cov, -@@ -168,6 +169,10 @@ +@@ -278,6 +279,10 @@ def _impl(ctx): name = "supports_start_end_lib", enabled = True, ) @@ -27,9 +28,9 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl + enabled = True, + ) - default_compile_flags_feature = feature( - name = "default_compile_flags", -@@ -203,7 +208,7 @@ + gcc_quoting_for_param_files_feature = feature( + name = "gcc_quoting_for_param_files", +@@ -323,7 +328,7 @@ def _impl(ctx): flags = ctx.attr.dbg_compile_flags, ), ] if ctx.attr.dbg_compile_flags else []), @@ -38,7 +39,7 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl ), flag_set( actions = all_compile_actions, -@@ -212,7 +217,7 @@ +@@ -332,7 +337,7 @@ def _impl(ctx): flags = ctx.attr.opt_compile_flags, ), ] if ctx.attr.opt_compile_flags else []), @@ -46,8 +47,8 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl + with_features = [with_feature_set(features = ["opt", "default_opt_level_flags"])], ), flag_set( - actions = all_cpp_compile_actions + [ACTION_NAMES.lto_backend], -@@ -244,7 +249,7 @@ + actions = [ACTION_NAMES.c_compile], +@@ -372,7 +377,7 @@ def _impl(ctx): flags = ctx.attr.opt_link_flags, ), ] if ctx.attr.opt_link_flags else []), @@ -55,32 +56,72 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl + with_features = [with_feature_set(features = ["opt", "default_opt_level_flags"])], ), ], + env_sets = [ +@@ -1473,27 +1478,6 @@ def _impl(ctx): + enabled = True, ) -@@ -1255,6 +1260,7 @@ + +- asan_feature = _sanitizer_feature( +- name = "asan", +- specific_compile_flags = [ +- "-fsanitize=address", +- "-fno-common", +- ], +- specific_link_flags = [ +- "-fsanitize=address", +- ], +- ) +- +- tsan_feature = _sanitizer_feature( +- name = "tsan", +- specific_compile_flags = [ +- "-fsanitize=thread", +- ], +- specific_link_flags = [ +- "-fsanitize=thread", +- ], +- ) +- + ubsan_feature = _sanitizer_feature( + name = "ubsan", + specific_compile_flags = [ +@@ -1569,11 +1553,10 @@ def _impl(ctx): strip_debug_symbols_feature, coverage_feature, supports_pic_feature, +- asan_feature, +- tsan_feature, + ubsan_feature, + gcc_quoting_for_param_files_feature, + static_link_cpp_runtimes_feature, + default_opt_level_flags_feature, ] + ( [ supports_start_end_lib_feature, -@@ -1276,6 +1282,7 @@ - else: - features = [ - supports_pic_feature, +@@ -1613,11 +1596,10 @@ def _impl(ctx): + set_install_name_feature, + libtool_feature, + archiver_flags_feature, +- asan_feature, +- tsan_feature, + ubsan_feature, + gcc_quoting_for_param_files_feature, + static_link_cpp_runtimes_feature, + default_opt_level_flags_feature, ] + ( [ supports_start_end_lib_feature, -@@ -1294,6 +1301,7 @@ - unfiltered_compile_flags_feature, - ] + layering_check_features(ctx.attr.compiler) +@@ -1643,8 +1625,8 @@ def _impl(ctx): + parse_headers_action_configs, parse_headers_features = parse_headers_support( + parse_headers_tool_path = ctx.attr.tool_paths.get("parse_headers"), + ) ++ features = pl_toolchain_pre_features(ctx) + features + parse_headers_features + pl_toolchain_post_features(ctx) + action_configs += parse_headers_action_configs +- features += parse_headers_features -+ features = pl_toolchain_pre_features(ctx) + features + pl_toolchain_post_features(ctx) - return cc_common.create_cc_toolchain_config_info( - ctx = ctx, - features = features, -@@ -1313,7 +1321,7 @@ + if symbol_check: + features.append(symbol_check) +@@ -1669,7 +1651,7 @@ def _impl(ctx): cc_toolchain_config = rule( implementation = _impl, @@ -89,11 +130,12 @@ diff --color -Naur a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl "cpu": attr.string(mandatory = True), "compiler": attr.string(mandatory = True), "toolchain_identifier": attr.string(mandatory = True), -@@ -1336,6 +1344,6 @@ - "coverage_link_flags": attr.string_list(), - "supports_start_end_lib": attr.bool(), - "builtin_sysroot": attr.string(), +@@ -1699,7 +1681,7 @@ cc_toolchain_config = rule( + fragment = "apple", + name = "xcode_config_label", + )), - }, + }, **PL_EXTRA_CC_CONFIG_ATTRS), + fragments = ["apple", "cpp"], provides = [CcToolchainConfigInfo], ) diff --git a/bazel/pl_build_system.bzl b/bazel/pl_build_system.bzl index 161784bd11b..82b6acb5e07 100644 --- a/bazel/pl_build_system.bzl +++ b/bazel/pl_build_system.bzl @@ -95,7 +95,8 @@ def pl_common_linkopts(): "-lunwind", ], # The OSX system library transitively links common libraries (e.g., pthread). - "@bazel_tools//tools/osx:darwin": [], + "@bazel_tools//tools/osx:darwin_arm64": [], + "@bazel_tools//tools/osx:darwin_x86_64": [], "//conditions:default": [ "-pthread", "-lunwind", diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index 3b5c832da59..dea2a4c9f8b 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -488,9 +488,9 @@ REPOSITORY_LOCATIONS = dict( ], ), unix_cc_toolchain_config = dict( - sha256 = "2c1d60ef4d586909f138c28409780e102e2ebd619e7d462ded26dce43a8f9ffb", + sha256 = "dfee9d4e56421497002c1bb932a1cf9323eca9273374419ca436e7d4b1421134", urls = [ - "https://raw.githubusercontent.com/bazelbuild/bazel/5.3.1/tools/cpp/unix_cc_toolchain_config.bzl", + "https://raw.githubusercontent.com/bazelbuild/bazel/7.7.1/tools/cpp/unix_cc_toolchain_config.bzl", ], ), # GRPC and Protobuf pick different versions. Pick the newer one. diff --git a/ci/cquery_ignore_non_target_and_incompatible.bzl b/ci/cquery_ignore_non_target_and_incompatible.bzl index ca748eebf77..3630b0c218c 100644 --- a/ci/cquery_ignore_non_target_and_incompatible.bzl +++ b/ci/cquery_ignore_non_target_and_incompatible.bzl @@ -17,8 +17,9 @@ def format(target): build_opts = build_options(target) - # We only want to get targets that are in the target configuration. So we ignore exec and host targets. - if build_opts["//command_line_option:is exec configuration"] or build_opts["//command_line_option:is host configuration"]: + # We only want to get targets that are in the target configuration. So we ignore exec targets. + # Note: "is host configuration" was removed in Bazel 7 as host configuration was fully replaced by exec configuration. + if build_opts["//command_line_option:is exec configuration"]: return None # Ignore targets that are incompatible with the target configuration. From e2bcd8614948de491756e3c9ced35af77d2251e7 Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Wed, 10 Dec 2025 19:53:49 +0000 Subject: [PATCH 3/5] Fix linting Signed-off-by: Dom Del Nano --- .arclint | 1 - 1 file changed, 1 deletion(-) diff --git a/.arclint b/.arclint index 2bb8b3b8303..7b87106fe80 100644 --- a/.arclint +++ b/.arclint @@ -34,7 +34,6 @@ "(^src/ui/src/types/schema\\.ts$)", "(^third_party/cpplint/cpplint.py$)", "(^third_party/gogoproto/gogo.proto$)", - "(^third_party/protoc-gen-grpc-web/grpc_generator.cc$)", "(c_cpp_properties.json$)", "(go\\.mod$)", "(go\\.sum$)" From eeaf88d3eb368f2b56b0deba627485b5cb7e62e3 Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Thu, 11 Dec 2025 17:34:19 +0000 Subject: [PATCH 4/5] Ensure bpf build also uses --host_features Signed-off-by: Dom Del Nano --- .bazelrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelrc b/.bazelrc index 46a47381321..b26aad0eec5 100644 --- a/.bazelrc +++ b/.bazelrc @@ -112,7 +112,7 @@ test:clang-libstdc++ --config=tmp-sandbox build:qemu-bpf --config=clang-base build:qemu-bpf --//bazel:enable_libcpp -build:qemu-bpf --features=libc++ --features=-libstdc++ +build:qemu-bpf --features=libc++ --features=-libstdc++ --host_features=libc++ --host_features=-libstdc++ build:qemu-bpf --build_tag_filters=requires_bpf,requires_root,-no_qemu,-no_libcpp build:qemu-bpf --test_tag_filters=requires_bpf,requires_root,-no_qemu,-no_libcpp,-disabled build:qemu-bpf --sandbox_fake_username From ac23be45328291a124332833cea61d53a5e8aac9 Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Thu, 11 Dec 2025 21:25:55 +0000 Subject: [PATCH 5/5] Update qemu test runner to fulfill bazel's interface for test sharding Signed-off-by: Dom Del Nano --- bazel/test_runners/qemu_with_kernel/launcher.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bazel/test_runners/qemu_with_kernel/launcher.sh b/bazel/test_runners/qemu_with_kernel/launcher.sh index d9dae814ded..8e8c230ab4c 100644 --- a/bazel/test_runners/qemu_with_kernel/launcher.sh +++ b/bazel/test_runners/qemu_with_kernel/launcher.sh @@ -25,6 +25,13 @@ RUN_QEMU_SCRIPT=%runqemuscript% # Create a tmp directory that serves as the /test_fs sanbox dir inside qemu. tmpdir_for_sandbox=$(mktemp -d) +# This file must be modified to signal to bazel that the qemu runner supports sharding. +# Since this runner leverages bazel's test runner and only runs supported binaries +# (googletest tests), we fulfill the requirement by touching this file. +if [ -n "${TEST_SHARD_STATUS_FILE}" ]; then + touch "${TEST_SHARD_STATUS_FILE}" +fi + # shellcheck disable=SC2317 function cleanup { retval=$?