Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[brpc] Fix build failed when protobuf update to 3.19.3 #22685

Merged
merged 12 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
251 changes: 251 additions & 0 deletions ports/brpc/fix-dependNewProtobuf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
diff --git a/src/brpc/esp_message.cpp b/src/brpc/esp_message.cpp
LilyWangLL marked this conversation as resolved.
Show resolved Hide resolved
index 0c93c12..583181d 100644
--- a/src/brpc/esp_message.cpp
+++ b/src/brpc/esp_message.cpp
@@ -52,6 +52,12 @@ EspMessage* EspMessage::New() const {
return new EspMessage;
}

+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+EspMessage* EspMessage::New(::google::protobuf::Arena* arena) const {
+ return CreateMaybeMessage<EspMessage>(arena);
+}
+#endif
+
void EspMessage::Clear() {
head.body_len = 0;
body.clear();
diff --git a/src/brpc/esp_message.h b/src/brpc/esp_message.h
index 1b23974..5ab5cfb 100644
--- a/src/brpc/esp_message.h
+++ b/src/brpc/esp_message.h
@@ -54,6 +54,9 @@ public:
// implements Message ----------------------------------------------

EspMessage* New() const;
+ #if GOOGLE_PROTOBUF_VERSION >= 3006000
+ EspMessage* New(::google::protobuf::Arena* arena) const override;
+ #endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const EspMessage& from);
diff --git a/src/brpc/memcache.cpp b/src/brpc/memcache.cpp
index cd7ea30..60d6c71 100644
--- a/src/brpc/memcache.cpp
+++ b/src/brpc/memcache.cpp
@@ -63,6 +63,12 @@ MemcacheRequest* MemcacheRequest::New() const {
return new MemcacheRequest;
}

+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+MemcacheRequest* MemcacheRequest::New(::google::protobuf::Arena* arena) const {
+ return CreateMaybeMessage<MemcacheRequest>(arena);
+}
+#endif
+
void MemcacheRequest::Clear() {
_buf.clear();
_pipelined_count = 0;
@@ -207,6 +213,13 @@ MemcacheResponse* MemcacheResponse::New() const {
return new MemcacheResponse;
}

+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+MemcacheResponse*
+MemcacheResponse::New(::google::protobuf::Arena* arena) const {
+ return CreateMaybeMessage<MemcacheResponse>(arena);
+}
+#endif
+
void MemcacheResponse::Clear() {
}

diff --git a/src/brpc/memcache.h b/src/brpc/memcache.h
index bd54c39..ab46457 100644
--- a/src/brpc/memcache.h
+++ b/src/brpc/memcache.h
@@ -90,6 +90,9 @@ public:

// Protobuf methods.
MemcacheRequest* New() const;
+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+ MemcacheRequest* New(::google::protobuf::Arena* arena) const override;
+#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const MemcacheRequest& from);
@@ -200,6 +203,9 @@ public:
// implements Message ----------------------------------------------

MemcacheResponse* New() const;
+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+ MemcacheResponse* New(::google::protobuf::Arena* arena) const override;
+#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const MemcacheResponse& from);
diff --git a/src/brpc/nshead_message.cpp b/src/brpc/nshead_message.cpp
index e58de2a..b74089a 100644
--- a/src/brpc/nshead_message.cpp
+++ b/src/brpc/nshead_message.cpp
@@ -54,6 +54,12 @@ NsheadMessage* NsheadMessage::New() const {
return new NsheadMessage;
}

+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+NsheadMessage* NsheadMessage::New(::google::protobuf::Arena* arena) const {
+ return CreateMaybeMessage<NsheadMessage>(arena);
+}
+#endif
+
void NsheadMessage::Clear() {
memset(&head, 0, sizeof(head));
body.clear();
diff --git a/src/brpc/nshead_message.h b/src/brpc/nshead_message.h
index 3f41454..de8810f 100644
--- a/src/brpc/nshead_message.h
+++ b/src/brpc/nshead_message.h
@@ -50,6 +50,9 @@ public:
// implements Message ----------------------------------------------

NsheadMessage* New() const;
+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+ NsheadMessage* New(::google::protobuf::Arena* arena) const override;
+#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const NsheadMessage& from);
diff --git a/src/brpc/protocol.cpp b/src/brpc/protocol.cpp
index c998edb..88aff5c 100644
--- a/src/brpc/protocol.cpp
+++ b/src/brpc/protocol.cpp
@@ -203,7 +203,11 @@ BUTIL_FORCE_INLINE bool ParsePbFromZeroCopyStreamInlined(
// According to source code of pb, SetTotalBytesLimit is not a simple set,
// avoid calling the function when the limit is definitely unreached.
if (PB_TOTAL_BYETS_LIMITS < FLAGS_max_body_size) {
+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+ decoder.SetTotalBytesLimit(INT_MAX);
+#else
decoder.SetTotalBytesLimit(INT_MAX, -1);
+#endif
}
return msg->ParseFromCodedStream(&decoder) && decoder.ConsumedEntireMessage();
}
diff --git a/src/brpc/redis.cpp b/src/brpc/redis.cpp
index 7cfc21f..4e12bac 100644
--- a/src/brpc/redis.cpp
+++ b/src/brpc/redis.cpp
@@ -59,6 +59,12 @@ RedisRequest* RedisRequest::New() const {
return new RedisRequest;
}

+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+RedisRequest* RedisRequest::New(::google::protobuf::Arena* arena) const {
+ return CreateMaybeMessage<RedisRequest>(arena);
+}
+#endif
+
void RedisRequest::Clear() {
_ncommand = 0;
_has_error = false;
@@ -271,6 +277,12 @@ RedisResponse* RedisResponse::New() const {
return new RedisResponse;
}

+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+RedisResponse* RedisResponse::New(::google::protobuf::Arena* arena) const {
+ return CreateMaybeMessage<RedisResponse>(arena);
+}
+#endif
+
void RedisResponse::Clear() {
_first_reply.Reset();
_other_replies = NULL;
diff --git a/src/brpc/redis.h b/src/brpc/redis.h
index d3f09e8..34dec77 100644
--- a/src/brpc/redis.h
+++ b/src/brpc/redis.h
@@ -107,6 +107,9 @@ public:

// Protobuf methods.
RedisRequest* New() const;
+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+ RedisRequest* New(::google::protobuf::Arena* arena) const override;
+#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const RedisRequest& from);
@@ -177,6 +180,9 @@ public:
// implements Message ----------------------------------------------

RedisResponse* New() const;
+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+ RedisResponse* New(::google::protobuf::Arena* arena) const override;
+#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const RedisResponse& from);
diff --git a/src/brpc/serialized_request.cpp b/src/brpc/serialized_request.cpp
index 23beeb7..499738f 100644
--- a/src/brpc/serialized_request.cpp
+++ b/src/brpc/serialized_request.cpp
@@ -53,6 +53,13 @@ SerializedRequest* SerializedRequest::New() const {
return new SerializedRequest;
}

+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+SerializedRequest*
+SerializedRequest::New(::google::protobuf::Arena* arena) const {
+ return CreateMaybeMessage<SerializedRequest>(arena);
+}
+#endif
+
void SerializedRequest::Clear() {
_serialized.clear();
}
diff --git a/src/brpc/serialized_request.h b/src/brpc/serialized_request.h
index c59495d..2e30dde 100644
--- a/src/brpc/serialized_request.h
+++ b/src/brpc/serialized_request.h
@@ -44,6 +44,9 @@ public:
// implements Message ----------------------------------------------

SerializedRequest* New() const;
+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+ SerializedRequest* New(::google::protobuf::Arena* arena) const override;
+#endif
void CopyFrom(const ::google::protobuf::Message& from);
void CopyFrom(const SerializedRequest& from);
void Clear();
diff --git a/src/brpc/thrift_message.cpp b/src/brpc/thrift_message.cpp
index c3be85a..77e812b 100644
--- a/src/brpc/thrift_message.cpp
+++ b/src/brpc/thrift_message.cpp
@@ -59,6 +59,13 @@ ThriftFramedMessage* ThriftFramedMessage::New() const {
return new ThriftFramedMessage;
}

+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+ThriftFramedMessage*
+ThriftFramedMessage::New(::google::protobuf::Arena* arena) const {
+ return CreateMaybeMessage<ThriftFramedMessage>(arena);
+}
+#endif
+
void ThriftFramedMessage::Clear() {
body.clear();
if (_own_raw_instance) {
diff --git a/src/brpc/thrift_message.h b/src/brpc/thrift_message.h
index a152b16..8d39548 100644
--- a/src/brpc/thrift_message.h
+++ b/src/brpc/thrift_message.h
@@ -84,6 +84,9 @@ public:
// implements Message ----------------------------------------------

ThriftFramedMessage* New() const;
+#if GOOGLE_PROTOBUF_VERSION >= 3006000
+ ThriftFramedMessage* New(::google::protobuf::Arena* arena) const override;
+#endif
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const ThriftFramedMessage& from);
13 changes: 0 additions & 13 deletions ports/brpc/fix-protobuf-deprecated.patch

This file was deleted.

17 changes: 7 additions & 10 deletions ports/brpc/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
vcpkg_fail_port_install(ON_TARGET "windows")
LilyWangLL marked this conversation as resolved.
Show resolved Hide resolved

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO apache/incubator-brpc
Expand All @@ -9,26 +7,25 @@ vcpkg_from_github(
PATCHES
fix_boost_ptr.patch
fix_thrift.patch
fix-protobuf-deprecated.patch
fix-dependNewProtobuf.patch #merge upstream PR https://github.com/apache/incubator-brpc/pull/1679
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DWITH_THRIFT=ON
-DWITH_MESALINK=OFF
-DWITH_GLOG=ON
)

vcpkg_install_cmake()
vcpkg_cmake_install()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/include/butil/third_party/superfasthash")

vcpkg_copy_pdbs()

file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

vcpkg_fixup_pkgconfig()
9 changes: 7 additions & 2 deletions ports/brpc/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "brpc",
"version-string": "0.9.7",
"port-version": 3,
"port-version": 4,
"description": "Industrial-grade RPC framework used throughout Baidu, with 1,000,000+ instances and thousands kinds of services, called \"baidu-rpc\" inside Baidu.",
"homepage": "https://github.com/apache/incubator-brpc",
"license": "Apache-2.0",
"supports": "!windows",
"dependencies": [
"gflags",
Expand All @@ -16,6 +17,10 @@
"zlib"
]
},
"thrift"
"thrift",
{
"name": "vcpkg-cmake",
"host": true
}
]
}
5 changes: 5 additions & 0 deletions versions/b-/brpc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "17c9dc7c90d1f6e94cf78407c73e4e1feeaf1210",
"version-string": "0.9.7",
"port-version": 4
},
{
"git-tree": "42b5a413e49655d73b772efa7642eefff429b4c1",
"version-string": "0.9.7",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@
},
"brpc": {
"baseline": "0.9.7",
"port-version": 3
"port-version": 4
},
"brunocodutra-metal": {
"baseline": "2.1.3",
Expand Down