Skip to content

Commit

Permalink
Upgrade protobuf to 26.1
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Avlasov <yavlasov@google.com>
  • Loading branch information
yanavlasov committed Jun 24, 2024
1 parent d2a20a0 commit 1547ca1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 39 deletions.
32 changes: 4 additions & 28 deletions bazel/protobuf.patch
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ index e7555ee10..a93beb1c5 100644
@@ -8,3 +8,10 @@
# Copyright 2007 Google Inc. All Rights Reserved.

__version__ = '4.25.3'
__version__ = '5.26.1'
+
+
+if __name__ != '__main__':
Expand All @@ -110,30 +110,18 @@ diff --git a/src/google/protobuf/io/BUILD.bazel b/src/google/protobuf/io/BUILD.b
}),
)

diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
--- a/src/google/protobuf/port_def.inc 2023-06-27 01:17:34.917105764 +0000
+++ b/src/google/protobuf/port_def.inc 2023-06-27 01:18:12.069060142 +0000
@@ -1004,7 +1004,7 @@
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
// Turn on -Wdeprecated-enum-enum-conversion. This deprecation comes in C++20
// via http://wg21.link/p1120r0.
-#pragma clang diagnostic error "-Wdeprecated-enum-enum-conversion"
+// #pragma clang diagnostic error "-Wdeprecated-enum-enum-conversion"
// This error has been generally flaky, but we need to disable it specifically
// to fix https://github.com/protocolbuffers/protobuf/issues/12313
#pragma clang diagnostic ignored "-Wunused-parameter"
diff --git a/src/google/protobuf/compiler/BUILD.bazel b/src/google/protobuf/compiler/BUILD.bazel
--- a/src/google/protobuf/compiler/BUILD.bazel
+++ b/src/google/protobuf/compiler/BUILD.bazel
@@ -306,7 +306,7 @@
srcs = ["retention.cc"],
hdrs = ["retention.h"],
include_prefix = "google/protobuf/compiler",
strip_include_prefix = "/src",
- visibility = ["//src/google/protobuf:__subpackages__"],
+ visibility = ["//visibility:public"],
deps = [
"//src/google/protobuf:protobuf_nowkt",
"@com_google_absl//absl/container:flat_hash_set",
"//src/google/protobuf",
"//src/google/protobuf:port",

diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
index 1c6a24945..c27d0bf2a 100644
Expand All @@ -149,15 +137,3 @@ index 1c6a24945..c27d0bf2a 100644
#if PROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII
#define PROTOBUF_DEBUG true
#else
diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc
--- a/src/google/protobuf/message_lite.cc 2024-04-19 15:49:01.333322873 +0000
+++ b/src/google/protobuf/message_lite.cc 2024-04-19 15:50:41.065136525 +0000
@@ -66,7 +66,7 @@

int MessageLite::GetCachedSize() const {
auto* cached_size = AccessCachedSize();
- if (PROTOBUF_PREDICT_FALSE(cached_size == nullptr)) return ByteSize();
+ if (PROTOBUF_PREDICT_FALSE(cached_size == nullptr)) return (int)ByteSizeLong();
return cached_size->Get();
}

16 changes: 8 additions & 8 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# This should match the schema defined in external_deps.bzl.

PROTOBUF_VERSION = "25.3"
PROTOBUF_VERSION = "26.1"

# These names of these deps *must* match the names used in `/bazel/protobuf.patch`,
# and both must match the names from the protobuf releases (see
# https://github.com/protocolbuffers/protobuf/releases).
# The names change in upcoming versions.
# The shas are calculated from the downloads on the releases page.
PROTOC_VERSIONS = dict(
linux_aarch_64 = "9eae1f20f70cccc912d1c318c3929b86aebf5afd4b0f32c196ef682c222ed5ae",
linux_x86_64 = "f853e691868d0557425ea290bf7ba6384eef2fa9b04c323afab49a770ba9da80",
osx_aarch_64 = "d0fcd6d3b3ef6f22f1c47cc30a80c06727e1eccdddcaf0f4a3be47c070ffd3fe",
osx_x86_64 = "247e003b8e115405172eacc50bd19825209d85940728e766f0848eee7c80e2a1",
win64 = "d6b336b852726364313330631656b7f395dde5b1141b169f5c4b8d43cdf01482",
linux_aarch_64 = "64a3b3b5f7dac0c8f9cf1cb85b2b1a237eb628644f6bcb0fb8f23db6e0d66181",
linux_x86_64 = "a7be2928c0454f132c599e25b79b7ad1b57663f2337d7f7e468a1d59b98ec1b0",
osx_aarch_64 = "26a29befa8891ecc48809958c909d284f2b9539a2eb47f22cadc631fe6abe8fd",
osx_x86_64 = "febd8821c3a2a23f72f4641471e0ab6486f4fb07b68111490a27a31681465b3c",
win64 = "9090d135a1159042b13b4e51b210e40cb820d85a5032a6eca5f9b3ca3bdfb539",
)

REPOSITORY_LOCATIONS_SPEC = dict(
Expand Down Expand Up @@ -933,11 +933,11 @@ REPOSITORY_LOCATIONS_SPEC = dict(
# test/common/json:gen_excluded_unicodes to recompute the ranges
# excluded from differential fuzzing that are populated in
# test/common/json/json_sanitizer_test_util.cc.
sha256 = "d19643d265b978383352b3143f04c0641eea75a75235c111cc01a1350173180e",
sha256 = "4fc5ff1b2c339fb86cd3a25f0b5311478ab081e65ad258c6789359cd84d421f8",
strip_prefix = "protobuf-{version}",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v{version}/protobuf-{version}.tar.gz"],
use_category = ["dataplane_core", "controlplane"],
release_date = "2024-02-15",
release_date = "2024-03-27",
cpe = "cpe:2.3:a:google:protobuf:*",
license = "Protocol Buffers",
license_url = "https://github.com/protocolbuffers/protobuf/blob/v{version}/LICENSE",
Expand Down
2 changes: 1 addition & 1 deletion source/common/common/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ absl::Status Registry::setJsonLogFormat(const Protobuf::Message& log_format_stru
#else
Protobuf::util::JsonPrintOptions json_options;
json_options.preserve_proto_field_names = true;
json_options.always_print_primitive_fields = true;
json_options.always_print_fields_with_no_presence = true;

std::string format_as_json;
const auto status =
Expand Down
2 changes: 1 addition & 1 deletion source/common/protobuf/yaml_utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ MessageUtil::getJsonStringFromMessage(const Protobuf::Message& message, const bo
// Primitive types such as int32s and enums will not be serialized if they have the default value.
// This flag disables that behavior.
if (always_print_primitive_fields) {
json_options.always_print_primitive_fields = true;
json_options.always_print_fields_with_no_presence = true;
}
std::string json;
if (auto status = Protobuf::util::MessageToJsonString(message, &json, json_options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ JsonTranscoderConfig::JsonTranscoderConfig(

const auto& print_config = proto_config.print_options();
response_translate_options_.json_print_options.add_whitespace = print_config.add_whitespace();
response_translate_options_.json_print_options.always_print_primitive_fields =
response_translate_options_.json_print_options.always_print_fields_with_no_presence =
print_config.always_print_primitive_fields();
response_translate_options_.json_print_options.always_print_enums_as_ints =
print_config.always_print_enums_as_ints();
Expand Down

0 comments on commit 1547ca1

Please sign in to comment.