Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.2.0
6.5.0
8 changes: 4 additions & 4 deletions bazel/external/grpc_go_toolchain.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 0 additions & 13 deletions bazel/external/grpc_test_visibility.patch

This file was deleted.

99 changes: 99 additions & 0 deletions bazel/external/protobuf_remove_absl_if_constexpr.patch
Original file line number Diff line number Diff line change
@@ -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 <typename T, typename... Args>
PROTOBUF_NDEBUG_INLINE static T* Create(Arena* arena, Args&&... args) {
- return absl::utility_internal::IfConstexprElse<
- is_arena_constructable<T>::value>(
- // Arena-constructable
- [arena](auto&&... args) {
- using Type = std::remove_const_t<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<T>::value) {
- constexpr auto construct_type = GetConstructType<T, Args&&...>();
- // 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<Type*>(DefaultConstruct<Type>(arena));
- } else if constexpr (construct_type == ConstructType::kCopy) {
- return static_cast<Type*>(CopyConstruct<Type>(arena, &args...));
- }
- }
-#endif
- return CreateArenaCompatible<Type>(arena,
- std::forward<Args>(args)...);
- },
- // Non arena-constructable
- [arena](auto&&... args) {
- if (PROTOBUF_PREDICT_FALSE(arena == nullptr)) {
- return new T(std::forward<Args>(args)...);
- }
- return new (arena->AllocateInternal<T>())
- T(std::forward<Args>(args)...);
- },
- std::forward<Args>(args)...);
+ if constexpr (is_arena_constructable<T>::value) {
+ using Type = std::remove_const_t<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<T>::value) {
+ constexpr auto construct_type = GetConstructType<T, Args&&...>();
+ // 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<Type*>(DefaultConstruct<Type>(arena));
+ } else if constexpr (construct_type == ConstructType::kCopy) {
+ return static_cast<Type*>(CopyConstruct<Type>(arena, &args...));
+ }
+ }
+ return CreateArenaCompatible<Type>(arena, std::forward<Args>(args)...);
+ } else {
+ if (ABSL_PREDICT_FALSE(arena == nullptr)) {
+ return new T(std::forward<Args>(args)...);
+ }
+ return new (arena->AllocateInternal<T>()) T(std::forward<Args>(args)...);
+ }
}

// API to delete any objects not on an arena. This can be used to safely
68 changes: 21 additions & 47 deletions bazel/external/protobuf_text_format.patch
Original file line number Diff line number Diff line change
@@ -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<int64_t>(s->size()) - max_length;
+ if (excess > 0) {
Expand All @@ -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<int64_t> 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);
Expand All @@ -60,39 +34,39 @@ index 19110499d..0d116ee7e 100644
- "...<truncated>...";
- 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, "...<truncated>..."), generator);
+ printer->PrintString(absl::StrCat(value_to_print, "...<truncated>..."), 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, "...<truncated>..."), generator);
+ printer->PrintBytes(absl::StrCat(value_to_print, "...<truncated>..."), 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) + "...<truncated>...");
+ generator->PrintString(absl::StrCat(absl::CEscape(value_to_print), "...<truncated>..."));
+ } else {
+ generator->PrintString(CEscape(value));
+ generator->PrintString(absl::CEscape(value));
+ }
if (single_line_mode_) {
generator->PrintLiteral("\" ");
Expand Down
16 changes: 8 additions & 8 deletions bazel/external/protobuf_warning.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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);
+ // }
}
}
Expand Down
11 changes: 8 additions & 3 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
35 changes: 14 additions & 21 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/common/grpcutils/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "src/common/base/base.h"

#include <grpcpp/grpcpp.h>

#include <chrono>
#include <string>

#include <absl/strings/str_format.h>
#include "src/common/base/base.h"
#include "src/common/grpcutils/logger.h"

using grpc::experimental::InterceptionHookPoints;
Expand Down
2 changes: 1 addition & 1 deletion src/stirling/e2e_tests/stirling_wrapper_size_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <utility>
#include <vector>
Expand Down
Loading