Skip to content

Commit 4f22c53

Browse files
committed
Upgrade to bazel (6.5.0), grpc (v1.64.2), protobuf (v27) and related deps
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent b81253e commit 4f22c53

11 files changed

Lines changed: 159 additions & 99 deletions

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.2.0
1+
6.5.0

bazel/external/grpc_go_toolchain.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ diff --git a/bazel/grpc_extra_deps.bzl b/bazel/grpc_extra_deps.bzl
22
index 4d8afa3131..514189f9a5 100644
33
--- a/bazel/grpc_extra_deps.bzl
44
+++ b/bazel/grpc_extra_deps.bzl
5-
@@ -53,7 +53,7 @@ def grpc_extra_deps(ignore_version_differences = False):
5+
@@ -63,7 +63,7 @@ def grpc_extra_deps(ignore_version_differences = False):
66
api_dependencies()
7-
7+
88
go_rules_dependencies()
9-
- go_register_toolchains(version = "1.18")
9+
- go_register_toolchains(version = "1.20")
1010
+ go_register_toolchains()
1111
gazelle_dependencies()
12-
12+
1313
# Pull-in the go 3rd party dependencies for protoc_gen_validate, which is

bazel/external/grpc_test_visibility.patch

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel
2+
index 917d9d35d..a90ebded0 100644
3+
--- a/src/google/protobuf/BUILD.bazel
4+
+++ b/src/google/protobuf/BUILD.bazel
5+
@@ -421,7 +421,6 @@ cc_library(
6+
"@com_google_absl//absl/numeric:bits",
7+
"@com_google_absl//absl/synchronization",
8+
"@com_google_absl//absl/types:span",
9+
- "@com_google_absl//absl/utility:if_constexpr",
10+
],
11+
)
12+
13+
@@ -545,7 +544,6 @@ cc_library(
14+
"@com_google_absl//absl/time",
15+
"@com_google_absl//absl/types:optional",
16+
"@com_google_absl//absl/types:span",
17+
- "@com_google_absl//absl/utility:if_constexpr",
18+
],
19+
)
20+
21+
diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h
22+
index c8ccfe24a..4ffe29b58 100644
23+
--- a/src/google/protobuf/arena.h
24+
+++ b/src/google/protobuf/arena.h
25+
@@ -30,7 +30,6 @@ using type_info = ::type_info;
26+
#include "absl/base/attributes.h"
27+
#include "google/protobuf/stubs/common.h"
28+
#include "absl/log/absl_check.h"
29+
-#include "absl/utility/internal/if_constexpr.h"
30+
#include "google/protobuf/arena_align.h"
31+
#include "google/protobuf/arena_allocation_policy.h"
32+
#include "google/protobuf/port.h"
33+
@@ -189,41 +188,31 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
34+
// otherwise, returns a heap-allocated object.
35+
template <typename T, typename... Args>
36+
PROTOBUF_NDEBUG_INLINE static T* Create(Arena* arena, Args&&... args) {
37+
- return absl::utility_internal::IfConstexprElse<
38+
- is_arena_constructable<T>::value>(
39+
- // Arena-constructable
40+
- [arena](auto&&... args) {
41+
- using Type = std::remove_const_t<T>;
42+
-#ifdef __cpp_if_constexpr
43+
- // DefaultConstruct/CopyConstruct are optimized for messages, which
44+
- // are both arena constructible and destructor skippable and they
45+
- // assume much. Don't use these functions unless the invariants
46+
- // hold.
47+
- if constexpr (is_destructor_skippable<T>::value) {
48+
- constexpr auto construct_type = GetConstructType<T, Args&&...>();
49+
- // We delegate to DefaultConstruct/CopyConstruct where appropriate
50+
- // because protobuf generated classes have external templates for
51+
- // these functions for code size reasons. When `if constexpr` is not
52+
- // available always use the fallback.
53+
- if constexpr (construct_type == ConstructType::kDefault) {
54+
- return static_cast<Type*>(DefaultConstruct<Type>(arena));
55+
- } else if constexpr (construct_type == ConstructType::kCopy) {
56+
- return static_cast<Type*>(CopyConstruct<Type>(arena, &args...));
57+
- }
58+
- }
59+
-#endif
60+
- return CreateArenaCompatible<Type>(arena,
61+
- std::forward<Args>(args)...);
62+
- },
63+
- // Non arena-constructable
64+
- [arena](auto&&... args) {
65+
- if (PROTOBUF_PREDICT_FALSE(arena == nullptr)) {
66+
- return new T(std::forward<Args>(args)...);
67+
- }
68+
- return new (arena->AllocateInternal<T>())
69+
- T(std::forward<Args>(args)...);
70+
- },
71+
- std::forward<Args>(args)...);
72+
+ if constexpr (is_arena_constructable<T>::value) {
73+
+ using Type = std::remove_const_t<T>;
74+
+ // DefaultConstruct/CopyConstruct are optimized for messages, which
75+
+ // are both arena constructible and destructor skippable and they
76+
+ // assume much. Don't use these functions unless the invariants
77+
+ // hold.
78+
+ if constexpr (is_destructor_skippable<T>::value) {
79+
+ constexpr auto construct_type = GetConstructType<T, Args&&...>();
80+
+ // We delegate to DefaultConstruct/CopyConstruct where appropriate
81+
+ // because protobuf generated classes have external templates for
82+
+ // these functions for code size reasons. When `if constexpr` is not
83+
+ // available always use the fallback.
84+
+ if constexpr (construct_type == ConstructType::kDefault) {
85+
+ return static_cast<Type*>(DefaultConstruct<Type>(arena));
86+
+ } else if constexpr (construct_type == ConstructType::kCopy) {
87+
+ return static_cast<Type*>(CopyConstruct<Type>(arena, &args...));
88+
+ }
89+
+ }
90+
+ return CreateArenaCompatible<Type>(arena, std::forward<Args>(args)...);
91+
+ } else {
92+
+ if (ABSL_PREDICT_FALSE(arena == nullptr)) {
93+
+ return new T(std::forward<Args>(args)...);
94+
+ }
95+
+ return new (arena->AllocateInternal<T>()) T(std::forward<Args>(args)...);
96+
+ }
97+
}
98+
99+
// API to delete any objects not on an arena. This can be used to safely

bazel/external/protobuf_text_format.patch

Lines changed: 21 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,13 @@
1-
diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc
2-
index 594c8eac6..c7ef9437b 100644
3-
--- a/src/google/protobuf/stubs/strutil.cc
4-
+++ b/src/google/protobuf/stubs/strutil.cc
5-
@@ -592,7 +592,7 @@ void CEscapeAndAppend(StringPiece src, std::string *dest) {
6-
}
7-
}
8-
9-
-std::string CEscape(const std::string &src) {
10-
+std::string CEscape(StringPiece src) {
11-
std::string dest;
12-
CEscapeAndAppend(src, &dest);
13-
return dest;
14-
diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h
15-
index 9658abf90..9cf9cae83 100644
16-
--- a/src/google/protobuf/stubs/strutil.h
17-
+++ b/src/google/protobuf/stubs/strutil.h
18-
@@ -328,7 +328,7 @@ PROTOBUF_EXPORT std::string UnescapeCEscapeString(const std::string& src);
19-
//
20-
// Escaped chars: \n, \r, \t, ", ', \, and !isprint().
21-
// ----------------------------------------------------------------------
22-
-PROTOBUF_EXPORT std::string CEscape(const std::string& src);
23-
+PROTOBUF_EXPORT std::string CEscape(StringPiece src);
24-
25-
// ----------------------------------------------------------------------
26-
// CEscapeAndAppend()
271
diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc
28-
index 19110499d..0d116ee7e 100644
2+
index 2c0a95d..1234567 100644
293
--- a/src/google/protobuf/text_format.cc
304
+++ b/src/google/protobuf/text_format.cc
31-
@@ -81,6 +81,18 @@ inline bool IsOctNumber(const std::string& str) {
5+
@@ -82,6 +82,18 @@ inline bool IsOctNumber(const std::string& str) {
326
(str[1] >= '0' && str[1] < '8'));
337
}
34-
35-
+// Returns true if truncatation occurred.
36-
+bool TruncateString(int64_t max_length, StringPiece* s) {
8+
9+
+// Returns true if truncation occurred.
10+
+bool TruncateString(int64_t max_length, absl::string_view* s) {
3711
+ if (max_length > 0) {
3812
+ int64_t excess = static_cast<int64_t>(s->size()) - max_length;
3913
+ if (excess > 0) {
@@ -44,10 +18,10 @@ index 19110499d..0d116ee7e 100644
4418
+ return false;
4519
+}
4620
+
47-
} // namespace
48-
49-
namespace internal {
50-
@@ -2555,20 +2567,22 @@ void TextFormat::Printer::PrintFieldValue(const Message& message,
21+
// The number of fields that are redacted in AbslStringify.
22+
std::atomic<int64_t> num_redacted_field{0};
23+
24+
@@ -2738,20 +2750,22 @@ void TextFormat::Printer::PrintFieldValue(const Message& message,
5125
? reflection->GetRepeatedStringReference(message, field, index,
5226
&scratch)
5327
: reflection->GetStringReference(message, field, &scratch);
@@ -60,39 +34,39 @@ index 19110499d..0d116ee7e 100644
6034
- "...<truncated>...";
6135
- value_to_print = &truncated_value;
6236
- }
63-
+ StringPiece value_to_print(value);
37+
+ absl::string_view value_to_print(value);
6438
+ bool truncated = TruncateString(truncate_string_field_longer_than_, &value_to_print);
6539
+
6640
if (field->type() == FieldDescriptor::TYPE_STRING) {
6741
- printer->PrintString(*value_to_print, generator);
6842
+ if (truncated) {
69-
+ printer->PrintString(StrCat(value_to_print, "...<truncated>..."), generator);
43+
+ printer->PrintString(absl::StrCat(value_to_print, "...<truncated>..."), generator);
7044
+ } else {
7145
+ printer->PrintString(value, generator);
7246
+ }
7347
} else {
74-
GOOGLE_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES);
48+
ABSL_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES);
7549
- printer->PrintBytes(*value_to_print, generator);
7650
+ if (truncated) {
77-
+ printer->PrintBytes(StrCat(value_to_print, "...<truncated>..."), generator);
51+
+ printer->PrintBytes(absl::StrCat(value_to_print, "...<truncated>..."), generator);
7852
+ } else {
7953
+ printer->PrintBytes(value, generator);
8054
+ }
8155
}
8256
break;
8357
}
84-
@@ -2708,7 +2722,14 @@ void TextFormat::Printer::PrintUnknownFields(
85-
// This field is not parseable as a Message (or we ran out of
86-
// recursion budget). So it is probably just a plain string.
87-
generator->PrintMaybeWithMarker(": ", "\"");
88-
- generator->PrintString(CEscape(value));
89-
+ StringPiece value_to_print(value);
58+
@@ -2937,7 +2951,14 @@ void TextFormat::Printer::PrintUnknownFields(
59+
break;
60+
}
61+
generator->PrintMaybeWithMarker(MarkerToken(), ": ", "\"");
62+
- generator->PrintString(absl::CEscape(value));
63+
+ absl::string_view value_to_print(value);
9064
+ bool truncated = TruncateString(truncate_string_field_longer_than_, &value_to_print);
9165
+
9266
+ if (truncated) {
93-
+ generator->PrintString(CEscape(value_to_print) + "...<truncated>...");
67+
+ generator->PrintString(absl::StrCat(absl::CEscape(value_to_print), "...<truncated>..."));
9468
+ } else {
95-
+ generator->PrintString(CEscape(value));
69+
+ generator->PrintString(absl::CEscape(value));
9670
+ }
9771
if (single_line_mode_) {
9872
generator->PrintLiteral("\" ");

bazel/external/protobuf_warning.patch

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ index 5e9a2c418..f95684bd1 100644
1414
virtual_path = "";
1515
disk_path = parts[i];
1616
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
17-
index 5f3427dc7..ab049c7c6 100644
17+
index 7456d3c3d..ddcd08c17 100644
1818
--- a/src/google/protobuf/descriptor.cc
1919
+++ b/src/google/protobuf/descriptor.cc
20-
@@ -8161,10 +8161,11 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto,
20+
@@ -10410,10 +10410,11 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto,
2121
if (is_error) {
22-
AddError((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT,
23-
error_message);
22+
AddError(unused->name(), proto, DescriptorPool::ErrorCollector::IMPORT,
23+
make_error);
2424
- } else {
25-
- AddWarning((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT,
26-
- error_message);
25+
- AddWarning(unused->name(), proto,
26+
- DescriptorPool::ErrorCollector::IMPORT, make_error);
2727
}
2828
+ // else {
29-
+ // AddWarning((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT,
30-
+ // error_message);
29+
+ // AddWarning(unused->name(), proto,
30+
+ // DescriptorPool::ErrorCollector::IMPORT, make_error);
3131
+ // }
3232
}
3333
}

bazel/repositories.bzl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,14 @@ def _com_llvm_lib():
120120
def _cc_deps():
121121
# Dependencies with native bazel build files.
122122

123-
_bazel_repo("upb")
124-
_bazel_repo("com_google_protobuf", patches = ["//bazel/external:protobuf_text_format.patch", "//bazel/external:protobuf_warning.patch"], patch_args = ["-p1"])
125-
_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"])
123+
_bazel_repo("rules_cc")
124+
_bazel_repo("com_google_protobuf", patches = [
125+
"//bazel/external:protobuf_text_format.patch",
126+
"//bazel/external:protobuf_warning.patch",
127+
# TODO(ddelnano): Remove once protobuf is upgraded to v31+
128+
"//bazel/external:protobuf_remove_absl_if_constexpr.patch"
129+
], patch_args = ["-p1"])
130+
_bazel_repo("com_github_grpc_grpc", patches = ["//bazel/external:grpc.patch", "//bazel/external:grpc_go_toolchain.patch"], patch_args = ["-p1"])
126131

127132
_bazel_repo("boringssl", patches = ["//bazel/external:boringssl.patch"], patch_args = ["-p0"])
128133
_bazel_repo("com_google_benchmark")

bazel/repository_locations.bzl

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ REPOSITORY_LOCATIONS = dict(
106106
urls = ["https://github.com/gperftools/gperftools/releases/download/gperftools-2.9.1/gperftools-2.9.1.tar.gz"],
107107
),
108108
com_github_grpc_grpc = dict(
109-
sha256 = "b55696fb249669744de3e71acc54a9382bea0dce7cd5ba379b356b12b82d4229",
110-
strip_prefix = "grpc-1.51.1",
111-
urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.51.1.tar.gz"],
109+
sha256 = "c682fc39baefc6e804d735e6b48141157b7213602cc66dbe0bf375b904d8b5f9",
110+
strip_prefix = "grpc-1.64.2",
111+
urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.64.2.tar.gz"],
112112
),
113113
# August 19, 2020.
114114
com_github_google_sentencepiece = dict(
@@ -232,9 +232,9 @@ REPOSITORY_LOCATIONS = dict(
232232
urls = ["https://github.com/pixie-io/libpypa/archive/eba8ec485a6c5e566d0d7a0716a06c91837c9d2f.tar.gz"],
233233
),
234234
com_google_absl = dict(
235-
sha256 = "91ac87d30cc6d79f9ab974c51874a704de9c2647c40f6932597329a282217ba8",
236-
strip_prefix = "abseil-cpp-20220623.1",
237-
urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20220623.1.tar.gz"],
235+
sha256 = "9b7a064305e9fd94d124ffa6cc358592eb42b5da588fb4e07d09254aa40086db",
236+
strip_prefix = "abseil-cpp-20250512.1",
237+
urls = ["https://github.com/abseil/abseil-cpp/archive/refs/tags/20250512.1.tar.gz"],
238238
),
239239
com_google_benchmark = dict(
240240
sha256 = "d26789a2b46d8808a48a4556ee58ccc7c497fcd4c0af9b90197674a81e04798a",
@@ -262,12 +262,9 @@ REPOSITORY_LOCATIONS = dict(
262262
urls = ["https://github.com/google/googletest/archive/refs/tags/v1.17.0.tar.gz"],
263263
),
264264
com_google_protobuf = dict(
265-
sha256 = "63c5539a8506dc6bccd352a857cea106e0a389ce047a3ff0a78fe3f8fede410d",
266-
strip_prefix = "protobuf-24487dd1045c7f3d64a21f38a3f0c06cc4cf2edb",
267-
urls = [
268-
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/protobuf/archive/24487dd1045c7f3d64a21f38a3f0c06cc4cf2edb.tar.gz",
269-
"https://github.com/protocolbuffers/protobuf/archive/24487dd1045c7f3d64a21f38a3f0c06cc4cf2edb.tar.gz",
270-
],
265+
sha256 = "da288bf1daa6c04d03a9051781caa52aceb9163586bff9aa6cfb12f69b9395aa",
266+
strip_prefix = "protobuf-27.0",
267+
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protobuf-27.0.tar.gz",]
271268
),
272269
com_google_protobuf_javascript = dict(
273270
sha256 = "35bca1729532b0a77280bf28ab5937438e3dcccd6b31a282d9ae84c896b6f6e3",
@@ -451,6 +448,11 @@ REPOSITORY_LOCATIONS = dict(
451448
urls = ["http://musl.libc.org/releases/musl-1.2.3.tar.gz"],
452449
manual_license_name = "libc/musl",
453450
),
451+
rules_cc = dict(
452+
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
453+
strip_prefix = "rules_cc-0.0.17",
454+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
455+
),
454456
rules_foreign_cc = dict(
455457
sha256 = "6041f1374ff32ba711564374ad8e007aef77f71561a7ce784123b9b4b88614fc",
456458
strip_prefix = "rules_foreign_cc-0.8.0",
@@ -479,15 +481,6 @@ REPOSITORY_LOCATIONS = dict(
479481
"https://raw.githubusercontent.com/bazelbuild/bazel/5.3.1/tools/cpp/unix_cc_toolchain_config.bzl",
480482
],
481483
),
482-
# GRPC and Protobuf pick different versions. Pick the newer one.
483-
upb = dict(
484-
sha256 = "017a7e8e4e842d01dba5dc8aa316323eee080cd1b75986a7d1f94d87220e6502",
485-
strip_prefix = "upb-e4635f223e7d36dfbea3b722a4ca4807a7e882e2",
486-
urls = [
487-
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz",
488-
"https://github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz",
489-
],
490-
),
491484
cpuinfo = dict(
492485
sha256 = "18eca9bc8d9c4ce5496d0d2be9f456d55cbbb5f0639a551ce9c8bac2e84d85fe",
493486
strip_prefix = "cpuinfo-5e63739504f0f8e18e941bd63b2d6d42536c7d90",

src/common/grpcutils/logger.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
* SPDX-License-Identifier: Apache-2.0
1717
*/
1818

19+
#include "src/common/base/base.h"
20+
1921
#include <grpcpp/grpcpp.h>
2022

2123
#include <chrono>
2224
#include <string>
2325

2426
#include <absl/strings/str_format.h>
25-
#include "src/common/base/base.h"
2627
#include "src/common/grpcutils/logger.h"
2728

2829
using grpc::experimental::InterceptionHookPoints;

src/stirling/e2e_tests/stirling_wrapper_size_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace stirling {
3030
#ifdef __OPTIMIZE__
3131
constexpr uint64_t kFileSizeLimitMB = 118;
3232
#else
33-
constexpr uint64_t kFileSizeLimitMB = 310;
33+
constexpr uint64_t kFileSizeLimitMB = 325;
3434
#endif
3535

3636
TEST(StirlingWrapperSizeTest, ExecutableSizeLimit) {

0 commit comments

Comments
 (0)