From 4f22c53fac8fe33a5c3e473e409272c279518cf6 Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Wed, 10 Dec 2025 23:44:25 +0000 Subject: [PATCH] Upgrade to bazel (6.5.0), grpc (v1.64.2), protobuf (v27) and related deps Signed-off-by: Dom Del Nano --- .bazelversion | 2 +- bazel/external/grpc_go_toolchain.patch | 8 +- bazel/external/grpc_test_visibility.patch | 13 --- .../protobuf_remove_absl_if_constexpr.patch | 99 +++++++++++++++++++ bazel/external/protobuf_text_format.patch | 68 ++++--------- bazel/external/protobuf_warning.patch | 16 +-- bazel/repositories.bzl | 11 ++- bazel/repository_locations.bzl | 35 +++---- src/common/grpcutils/logger.cc | 3 +- .../e2e_tests/stirling_wrapper_size_test.cc | 2 +- .../socket_tracer/uprobe_manager.h | 1 + 11 files changed, 159 insertions(+), 99 deletions(-) delete mode 100644 bazel/external/grpc_test_visibility.patch create mode 100644 bazel/external/protobuf_remove_absl_if_constexpr.patch diff --git a/.bazelversion b/.bazelversion index 6abaeb2f907..f22d756da39 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.2.0 +6.5.0 diff --git a/bazel/external/grpc_go_toolchain.patch b/bazel/external/grpc_go_toolchain.patch index ec53b23de78..0e0941360d6 100644 --- a/bazel/external/grpc_go_toolchain.patch +++ b/bazel/external/grpc_go_toolchain.patch @@ -2,12 +2,12 @@ diff --git a/bazel/grpc_extra_deps.bzl b/bazel/grpc_extra_deps.bzl index 4d8afa3131..514189f9a5 100644 --- a/bazel/grpc_extra_deps.bzl +++ b/bazel/grpc_extra_deps.bzl -@@ -53,7 +53,7 @@ def grpc_extra_deps(ignore_version_differences = False): +@@ -63,7 +63,7 @@ def grpc_extra_deps(ignore_version_differences = False): api_dependencies() - + go_rules_dependencies() -- go_register_toolchains(version = "1.18") +- go_register_toolchains(version = "1.20") + go_register_toolchains() gazelle_dependencies() - + # Pull-in the go 3rd party dependencies for protoc_gen_validate, which is diff --git a/bazel/external/grpc_test_visibility.patch b/bazel/external/grpc_test_visibility.patch deleted file mode 100644 index 05f7ba64831..00000000000 --- a/bazel/external/grpc_test_visibility.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/BUILD b/BUILD -index cb6cdc2891..c4d7f2ab8c 100644 ---- a/BUILD -+++ b/BUILD -@@ -2073,7 +2073,7 @@ grpc_cc_library( - "include/grpcpp/test/mock_stream.h", - "include/grpcpp/test/server_context_test_spouse.h", - ], -- visibility = ["@grpc:grpc++_test"], -+ visibility = ["//visibility:public"], - deps = [ - "grpc++", - "grpc_base", diff --git a/bazel/external/protobuf_remove_absl_if_constexpr.patch b/bazel/external/protobuf_remove_absl_if_constexpr.patch new file mode 100644 index 00000000000..b97e5898b1f --- /dev/null +++ b/bazel/external/protobuf_remove_absl_if_constexpr.patch @@ -0,0 +1,99 @@ +diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel +index 917d9d35d..a90ebded0 100644 +--- a/src/google/protobuf/BUILD.bazel ++++ b/src/google/protobuf/BUILD.bazel +@@ -421,7 +421,6 @@ cc_library( + "@com_google_absl//absl/numeric:bits", + "@com_google_absl//absl/synchronization", + "@com_google_absl//absl/types:span", +- "@com_google_absl//absl/utility:if_constexpr", + ], + ) + +@@ -545,7 +544,6 @@ cc_library( + "@com_google_absl//absl/time", + "@com_google_absl//absl/types:optional", + "@com_google_absl//absl/types:span", +- "@com_google_absl//absl/utility:if_constexpr", + ], + ) + +diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h +index c8ccfe24a..4ffe29b58 100644 +--- a/src/google/protobuf/arena.h ++++ b/src/google/protobuf/arena.h +@@ -30,7 +30,6 @@ using type_info = ::type_info; + #include "absl/base/attributes.h" + #include "google/protobuf/stubs/common.h" + #include "absl/log/absl_check.h" +-#include "absl/utility/internal/if_constexpr.h" + #include "google/protobuf/arena_align.h" + #include "google/protobuf/arena_allocation_policy.h" + #include "google/protobuf/port.h" +@@ -189,41 +188,31 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { + // otherwise, returns a heap-allocated object. + template + PROTOBUF_NDEBUG_INLINE static T* Create(Arena* arena, Args&&... args) { +- return absl::utility_internal::IfConstexprElse< +- is_arena_constructable::value>( +- // Arena-constructable +- [arena](auto&&... args) { +- using Type = std::remove_const_t; +-#ifdef __cpp_if_constexpr +- // DefaultConstruct/CopyConstruct are optimized for messages, which +- // are both arena constructible and destructor skippable and they +- // assume much. Don't use these functions unless the invariants +- // hold. +- if constexpr (is_destructor_skippable::value) { +- constexpr auto construct_type = GetConstructType(); +- // We delegate to DefaultConstruct/CopyConstruct where appropriate +- // because protobuf generated classes have external templates for +- // these functions for code size reasons. When `if constexpr` is not +- // available always use the fallback. +- if constexpr (construct_type == ConstructType::kDefault) { +- return static_cast(DefaultConstruct(arena)); +- } else if constexpr (construct_type == ConstructType::kCopy) { +- return static_cast(CopyConstruct(arena, &args...)); +- } +- } +-#endif +- return CreateArenaCompatible(arena, +- std::forward(args)...); +- }, +- // Non arena-constructable +- [arena](auto&&... args) { +- if (PROTOBUF_PREDICT_FALSE(arena == nullptr)) { +- return new T(std::forward(args)...); +- } +- return new (arena->AllocateInternal()) +- T(std::forward(args)...); +- }, +- std::forward(args)...); ++ if constexpr (is_arena_constructable::value) { ++ using Type = std::remove_const_t; ++ // DefaultConstruct/CopyConstruct are optimized for messages, which ++ // are both arena constructible and destructor skippable and they ++ // assume much. Don't use these functions unless the invariants ++ // hold. ++ if constexpr (is_destructor_skippable::value) { ++ constexpr auto construct_type = GetConstructType(); ++ // We delegate to DefaultConstruct/CopyConstruct where appropriate ++ // because protobuf generated classes have external templates for ++ // these functions for code size reasons. When `if constexpr` is not ++ // available always use the fallback. ++ if constexpr (construct_type == ConstructType::kDefault) { ++ return static_cast(DefaultConstruct(arena)); ++ } else if constexpr (construct_type == ConstructType::kCopy) { ++ return static_cast(CopyConstruct(arena, &args...)); ++ } ++ } ++ return CreateArenaCompatible(arena, std::forward(args)...); ++ } else { ++ if (ABSL_PREDICT_FALSE(arena == nullptr)) { ++ return new T(std::forward(args)...); ++ } ++ return new (arena->AllocateInternal()) T(std::forward(args)...); ++ } + } + + // API to delete any objects not on an arena. This can be used to safely diff --git a/bazel/external/protobuf_text_format.patch b/bazel/external/protobuf_text_format.patch index 0da75da7de7..59f88c6d44c 100644 --- a/bazel/external/protobuf_text_format.patch +++ b/bazel/external/protobuf_text_format.patch @@ -1,39 +1,13 @@ -diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc -index 594c8eac6..c7ef9437b 100644 ---- a/src/google/protobuf/stubs/strutil.cc -+++ b/src/google/protobuf/stubs/strutil.cc -@@ -592,7 +592,7 @@ void CEscapeAndAppend(StringPiece src, std::string *dest) { - } - } - --std::string CEscape(const std::string &src) { -+std::string CEscape(StringPiece src) { - std::string dest; - CEscapeAndAppend(src, &dest); - return dest; -diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h -index 9658abf90..9cf9cae83 100644 ---- a/src/google/protobuf/stubs/strutil.h -+++ b/src/google/protobuf/stubs/strutil.h -@@ -328,7 +328,7 @@ PROTOBUF_EXPORT std::string UnescapeCEscapeString(const std::string& src); - // - // Escaped chars: \n, \r, \t, ", ', \, and !isprint(). - // ---------------------------------------------------------------------- --PROTOBUF_EXPORT std::string CEscape(const std::string& src); -+PROTOBUF_EXPORT std::string CEscape(StringPiece src); - - // ---------------------------------------------------------------------- - // CEscapeAndAppend() diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc -index 19110499d..0d116ee7e 100644 +index 2c0a95d..1234567 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc -@@ -81,6 +81,18 @@ inline bool IsOctNumber(const std::string& str) { +@@ -82,6 +82,18 @@ inline bool IsOctNumber(const std::string& str) { (str[1] >= '0' && str[1] < '8')); } - -+// Returns true if truncatation occurred. -+bool TruncateString(int64_t max_length, StringPiece* s) { + ++// Returns true if truncation occurred. ++bool TruncateString(int64_t max_length, absl::string_view* s) { + if (max_length > 0) { + int64_t excess = static_cast(s->size()) - max_length; + if (excess > 0) { @@ -44,10 +18,10 @@ index 19110499d..0d116ee7e 100644 + return false; +} + - } // namespace - - namespace internal { -@@ -2555,20 +2567,22 @@ void TextFormat::Printer::PrintFieldValue(const Message& message, + // The number of fields that are redacted in AbslStringify. + std::atomic num_redacted_field{0}; + +@@ -2738,20 +2750,22 @@ void TextFormat::Printer::PrintFieldValue(const Message& message, ? reflection->GetRepeatedStringReference(message, field, index, &scratch) : reflection->GetStringReference(message, field, &scratch); @@ -60,39 +34,39 @@ index 19110499d..0d116ee7e 100644 - "......"; - value_to_print = &truncated_value; - } -+ StringPiece value_to_print(value); ++ absl::string_view value_to_print(value); + bool truncated = TruncateString(truncate_string_field_longer_than_, &value_to_print); + if (field->type() == FieldDescriptor::TYPE_STRING) { - printer->PrintString(*value_to_print, generator); + if (truncated) { -+ printer->PrintString(StrCat(value_to_print, "......"), generator); ++ printer->PrintString(absl::StrCat(value_to_print, "......"), generator); + } else { + printer->PrintString(value, generator); + } } else { - GOOGLE_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES); + ABSL_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES); - printer->PrintBytes(*value_to_print, generator); + if (truncated) { -+ printer->PrintBytes(StrCat(value_to_print, "......"), generator); ++ printer->PrintBytes(absl::StrCat(value_to_print, "......"), generator); + } else { + printer->PrintBytes(value, generator); + } } break; } -@@ -2708,7 +2722,14 @@ void TextFormat::Printer::PrintUnknownFields( - // This field is not parseable as a Message (or we ran out of - // recursion budget). So it is probably just a plain string. - generator->PrintMaybeWithMarker(": ", "\""); -- generator->PrintString(CEscape(value)); -+ StringPiece value_to_print(value); +@@ -2937,7 +2951,14 @@ void TextFormat::Printer::PrintUnknownFields( + break; + } + generator->PrintMaybeWithMarker(MarkerToken(), ": ", "\""); +- generator->PrintString(absl::CEscape(value)); ++ absl::string_view value_to_print(value); + bool truncated = TruncateString(truncate_string_field_longer_than_, &value_to_print); + + if (truncated) { -+ generator->PrintString(CEscape(value_to_print) + "......"); ++ generator->PrintString(absl::StrCat(absl::CEscape(value_to_print), "......")); + } else { -+ generator->PrintString(CEscape(value)); ++ generator->PrintString(absl::CEscape(value)); + } if (single_line_mode_) { generator->PrintLiteral("\" "); diff --git a/bazel/external/protobuf_warning.patch b/bazel/external/protobuf_warning.patch index 281ec297e1c..82203a2b6a0 100644 --- a/bazel/external/protobuf_warning.patch +++ b/bazel/external/protobuf_warning.patch @@ -14,20 +14,20 @@ index 5e9a2c418..f95684bd1 100644 virtual_path = ""; disk_path = parts[i]; diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc -index 5f3427dc7..ab049c7c6 100644 +index 7456d3c3d..ddcd08c17 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc -@@ -8161,10 +8161,11 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto, +@@ -10410,10 +10410,11 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto, if (is_error) { - AddError((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT, - error_message); + AddError(unused->name(), proto, DescriptorPool::ErrorCollector::IMPORT, + make_error); - } else { -- AddWarning((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT, -- error_message); +- AddWarning(unused->name(), proto, +- DescriptorPool::ErrorCollector::IMPORT, make_error); } + // else { -+ // AddWarning((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT, -+ // error_message); ++ // AddWarning(unused->name(), proto, ++ // DescriptorPool::ErrorCollector::IMPORT, make_error); + // } } } diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 55d23e61323..1b3f95e44ee 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -120,9 +120,14 @@ def _com_llvm_lib(): def _cc_deps(): # Dependencies with native bazel build files. - _bazel_repo("upb") - _bazel_repo("com_google_protobuf", patches = ["//bazel/external:protobuf_text_format.patch", "//bazel/external:protobuf_warning.patch"], patch_args = ["-p1"]) - _bazel_repo("com_github_grpc_grpc", patches = ["//bazel/external:grpc.patch", "//bazel/external:grpc_go_toolchain.patch", "//bazel/external:grpc_test_visibility.patch"], patch_args = ["-p1"]) + _bazel_repo("rules_cc") + _bazel_repo("com_google_protobuf", patches = [ + "//bazel/external:protobuf_text_format.patch", + "//bazel/external:protobuf_warning.patch", + # TODO(ddelnano): Remove once protobuf is upgraded to v31+ + "//bazel/external:protobuf_remove_absl_if_constexpr.patch" + ], patch_args = ["-p1"]) + _bazel_repo("com_github_grpc_grpc", patches = ["//bazel/external:grpc.patch", "//bazel/external:grpc_go_toolchain.patch"], patch_args = ["-p1"]) _bazel_repo("boringssl", patches = ["//bazel/external:boringssl.patch"], patch_args = ["-p0"]) _bazel_repo("com_google_benchmark") diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index 0a2df3dcb80..62ddb802cb4 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -106,9 +106,9 @@ REPOSITORY_LOCATIONS = dict( urls = ["https://github.com/gperftools/gperftools/releases/download/gperftools-2.9.1/gperftools-2.9.1.tar.gz"], ), com_github_grpc_grpc = dict( - sha256 = "b55696fb249669744de3e71acc54a9382bea0dce7cd5ba379b356b12b82d4229", - strip_prefix = "grpc-1.51.1", - urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.51.1.tar.gz"], + sha256 = "c682fc39baefc6e804d735e6b48141157b7213602cc66dbe0bf375b904d8b5f9", + strip_prefix = "grpc-1.64.2", + urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.64.2.tar.gz"], ), # August 19, 2020. com_github_google_sentencepiece = dict( @@ -232,9 +232,9 @@ REPOSITORY_LOCATIONS = dict( urls = ["https://github.com/pixie-io/libpypa/archive/eba8ec485a6c5e566d0d7a0716a06c91837c9d2f.tar.gz"], ), com_google_absl = dict( - sha256 = "91ac87d30cc6d79f9ab974c51874a704de9c2647c40f6932597329a282217ba8", - strip_prefix = "abseil-cpp-20220623.1", - urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20220623.1.tar.gz"], + sha256 = "9b7a064305e9fd94d124ffa6cc358592eb42b5da588fb4e07d09254aa40086db", + strip_prefix = "abseil-cpp-20250512.1", + urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20250512.1.tar.gz"], ), com_google_benchmark = dict( sha256 = "d26789a2b46d8808a48a4556ee58ccc7c497fcd4c0af9b90197674a81e04798a", @@ -262,12 +262,9 @@ REPOSITORY_LOCATIONS = dict( urls = ["https://github.com/google/googletest/archive/refs/tags/v1.17.0.tar.gz"], ), com_google_protobuf = dict( - sha256 = "63c5539a8506dc6bccd352a857cea106e0a389ce047a3ff0a78fe3f8fede410d", - strip_prefix = "protobuf-24487dd1045c7f3d64a21f38a3f0c06cc4cf2edb", - urls = [ - "https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/protobuf/archive/24487dd1045c7f3d64a21f38a3f0c06cc4cf2edb.tar.gz", - "https://github.com/protocolbuffers/protobuf/archive/24487dd1045c7f3d64a21f38a3f0c06cc4cf2edb.tar.gz", - ], + sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa", + strip_prefix = "protobuf-27.0", + urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",] ), com_google_protobuf_javascript = dict( sha256 = "35bca1729532b0a77280bf28ab5937438e3dcccd6b31a282d9ae84c896b6f6e3", @@ -451,6 +448,11 @@ REPOSITORY_LOCATIONS = dict( urls = ["http://musl.libc.org/releases/musl-1.2.3.tar.gz"], manual_license_name = "libc/musl", ), + rules_cc = dict( + sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1", + strip_prefix = "rules_cc-0.0.17", + urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"], + ), rules_foreign_cc = dict( sha256 = "6041f1374ff32ba711564374ad8e007aef77f71561a7ce784123b9b4b88614fc", strip_prefix = "rules_foreign_cc-0.8.0", @@ -479,15 +481,6 @@ REPOSITORY_LOCATIONS = dict( "https://raw.githubusercontent.com/bazelbuild/bazel/5.3.1/tools/cpp/unix_cc_toolchain_config.bzl", ], ), - # GRPC and Protobuf pick different versions. Pick the newer one. - upb = dict( - sha256 = "017a7e8e4e842d01dba5dc8aa316323eee080cd1b75986a7d1f94d87220e6502", - strip_prefix = "upb-e4635f223e7d36dfbea3b722a4ca4807a7e882e2", - urls = [ - "https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz", - "https://github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz", - ], - ), cpuinfo = dict( sha256 = "18eca9bc8d9c4ce5496d0d2be9f456d55cbbb5f0639a551ce9c8bac2e84d85fe", strip_prefix = "cpuinfo-5e63739504f0f8e18e941bd63b2d6d42536c7d90", diff --git a/src/common/grpcutils/logger.cc b/src/common/grpcutils/logger.cc index 0651c1ff54d..341fe57ab1a 100644 --- a/src/common/grpcutils/logger.cc +++ b/src/common/grpcutils/logger.cc @@ -16,13 +16,14 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include "src/common/base/base.h" + #include #include #include #include -#include "src/common/base/base.h" #include "src/common/grpcutils/logger.h" using grpc::experimental::InterceptionHookPoints; diff --git a/src/stirling/e2e_tests/stirling_wrapper_size_test.cc b/src/stirling/e2e_tests/stirling_wrapper_size_test.cc index 0718b01c3b3..dbc390b1816 100644 --- a/src/stirling/e2e_tests/stirling_wrapper_size_test.cc +++ b/src/stirling/e2e_tests/stirling_wrapper_size_test.cc @@ -30,7 +30,7 @@ namespace stirling { #ifdef __OPTIMIZE__ constexpr uint64_t kFileSizeLimitMB = 118; #else -constexpr uint64_t kFileSizeLimitMB = 310; +constexpr uint64_t kFileSizeLimitMB = 325; #endif TEST(StirlingWrapperSizeTest, ExecutableSizeLimit) { diff --git a/src/stirling/source_connectors/socket_tracer/uprobe_manager.h b/src/stirling/source_connectors/socket_tracer/uprobe_manager.h index 41d6e3c8157..858b5d838f1 100644 --- a/src/stirling/source_connectors/socket_tracer/uprobe_manager.h +++ b/src/stirling/source_connectors/socket_tracer/uprobe_manager.h @@ -20,6 +20,7 @@ #include #include +#include #include #include #include