[protobuf] upgrade to latest release (v3.18.0) (#20208)

* [protobuf] upgrade to latest release (v3.18.0)

This requires patching OpenCV as it uses a function removed in the
latest version of protobuf (FWIW, upstream OpenCV has a similar patch).

* The arcus port also needs a patch

* The caffe2 port also needs a patch

* The brpc port also needs a patch
This commit is contained in:
Carlos O'Ryan 2021-09-22 13:09:55 -07:00 коммит произвёл GitHub
Родитель 93885afd50
Коммит b29f8ef37e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
23 изменённых файлов: 128 добавлений и 34 удалений

Просмотреть файл

@ -0,0 +1,13 @@
diff --git a/src/Socket_p.h b/src/Socket_p.h
index 9c3c084..9ccabda 100644
--- a/src/Socket_p.h
+++ b/src/Socket_p.h
@@ -548,7 +548,7 @@ namespace Arcus
google::protobuf::io::ArrayInputStream array(wire_message->data, wire_message->size);
google::protobuf::io::CodedInputStream stream(&array);
- stream.SetTotalBytesLimit(message_size_maximum, message_size_warning);
+ stream.SetTotalBytesLimit(message_size_maximum);
if(!message->ParseFromCodedStream(&stream))
{
error(ErrorCode::ParseFailedError, "Failed to parse message:" + std::string(wire_message->data));

Просмотреть файл

@ -6,6 +6,8 @@ vcpkg_from_github(
REF 617f6f71572090f73cb44592b12f49567b539e5b #v4.10.0
SHA512 cf0954d8b10d9f94165aa5c086d0e58c2925464f9fbe4252535c36d7e6bb12b767d89efb816c9e642f9cd7f0ec0d66d61ca21c5121a05340499d38d5d851f73b
HEAD_REF master
PATCHES
0001-fix-protobuf-deprecated.patch
)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ENABLE_STATIC)

Просмотреть файл

@ -1,6 +1,7 @@
{
"name": "arcus",
"version-semver": "4.10.0",
"port-version": 1,
"description": "This library contains C++ bindings for creating a socket in a thread and using this socket to send and receive messages based on the Protocol Buffers library.",
"homepage": "https://github.com/Ultimaker/libArcus",
"supports": "!uwp",

Просмотреть файл

@ -0,0 +1,13 @@
diff --git a/src/brpc/protocol.cpp b/src/brpc/protocol.cpp
index 11297ea..c998edb 100644
--- a/src/brpc/protocol.cpp
+++ b/src/brpc/protocol.cpp
@@ -203,7 +203,7 @@ 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) {
- decoder.SetTotalBytesLimit(INT_MAX, -1);
+ decoder.SetTotalBytesLimit(INT_MAX);
}
return msg->ParseFromCodedStream(&decoder) && decoder.ConsumedEntireMessage();
}

Просмотреть файл

@ -9,6 +9,7 @@ vcpkg_from_github(
PATCHES
fix_boost_ptr.patch
fix_thrift.patch
fix-protobuf-deprecated.patch
)
vcpkg_configure_cmake(

Просмотреть файл

@ -1,7 +1,7 @@
{
"name": "brpc",
"version-string": "0.9.7",
"port-version": 1,
"port-version": 2,
"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",
"supports": "!windows",

Просмотреть файл

@ -0,0 +1,26 @@
diff --git a/caffe2/utils/proto_utils.cc b/caffe2/utils/proto_utils.cc
index ab2d756..2c36ec4 100644
--- a/caffe2/utils/proto_utils.cc
+++ b/caffe2/utils/proto_utils.cc
@@ -102,10 +102,9 @@ bool ReadProtoFromBinaryFile(const char* filename, MessageLite* proto) {
::google::protobuf::io::CopyingInputStreamAdaptor stream(
new IfstreamInputStream(filename));
stream.SetOwnsCopyingStream(true);
- // Total bytes hard limit / warning limit are set to 1GB and 512MB
- // respectively.
+ // Total bytes hard limit is set to 1GB.
::google::protobuf::io::CodedInputStream coded_stream(&stream);
- coded_stream.SetTotalBytesLimit(1024LL << 20, 512LL << 20);
+ coded_stream.SetTotalBytesLimit(1024LL << 20);
return proto->ParseFromCodedStream(&coded_stream);
}
@@ -155,7 +154,7 @@ bool ReadProtoFromBinaryFile(const char* filename, MessageLite* proto) {
std::unique_ptr<CodedInputStream> coded_input(
new CodedInputStream(raw_input.get()));
// A hack to manually allow using very large protocol buffers.
- coded_input->SetTotalBytesLimit(1073741824, 536870912);
+ coded_input->SetTotalBytesLimit(1073741824);
bool success = proto->ParseFromCodedStream(coded_input.get());
coded_input.reset();
raw_input.reset();

Просмотреть файл

@ -13,6 +13,7 @@ vcpkg_from_github(
PATCHES
msvc-fixes.patch
fix-space.patch
fix-protobuf-deprecated.patch
)
if(VCPKG_CRT_LINKAGE STREQUAL static)

Просмотреть файл

@ -1,7 +1,7 @@
{
"name": "caffe2",
"version-string": "0.8.1",
"port-version": 4,
"port-version": 5,
"description": "Caffe2 is a lightweight, modular, and scalable deep learning framework.",
"homepage": "https://github.com/caffe2/caffe2",
"supports": "!x86",

Просмотреть файл

@ -0,0 +1,13 @@
diff --git a/modules/dnn/src/caffe/caffe_io.cpp b/modules/dnn/src/caffe/caffe_io.cpp
index 2fc4d84..779d0dd 100644
--- a/modules/dnn/src/caffe/caffe_io.cpp
+++ b/modules/dnn/src/caffe/caffe_io.cpp
@@ -1111,7 +1111,7 @@ static const int kProtoReadBytesLimit = INT_MAX; // Max size of 2 GB minus 1 by
bool ReadProtoFromBinary(ZeroCopyInputStream* input, Message *proto) {
CodedInputStream coded_input(input);
- coded_input.SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);
+ coded_input.SetTotalBytesLimit(kProtoReadBytesLimit);
return proto->ParseFromCodedStream(&coded_input);
}

Просмотреть файл

@ -24,6 +24,7 @@ vcpkg_from_github(
0008-devendor-quirc.patch
0009-fix-protobuf.patch
0010-fix-uwp-tiff-imgcodecs.patch
0011-fix-caffe-io.patch
)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")

Просмотреть файл

@ -1,7 +1,7 @@
{
"name": "opencv4",
"version": "4.5.3",
"port-version": 1,
"port-version": 2,
"description": "computer vision library",
"homepage": "https://github.com/opencv/opencv",
"dependencies": [

Просмотреть файл

@ -1,11 +1,11 @@
diff --git a/cmake/install.cmake b/cmake/install.cmake
index 4091bc8..9850018 100644
index ef5bb13..e2d4acb 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -31,7 +31,7 @@ endforeach()
if (protobuf_BUILD_PROTOC_BINARIES)
install(TARGETS protoc EXPORT protobuf-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
@@ -33,7 +33,7 @@ if (protobuf_BUILD_PROTOC_BINARIES)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT protoc)
- if (UNIX AND NOT APPLE)
+ if (UNIX AND NOT APPLE AND NOT protobuf_MSVC_STATIC_RUNTIME)
set_property(TARGET protoc

Просмотреть файл

@ -0,0 +1,13 @@
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
index b6c31fd..8b77c3d 100644
--- a/src/google/protobuf/descriptor.cc
+++ b/src/google/protobuf/descriptor.cc
@@ -794,7 +794,7 @@ class TableArena {
size = RoundUp(size);
Block* to_relocate = nullptr;
- Block* to_use;
+ Block* to_use = nullptr;
for (size_t i = 0; i < kSmallSizes.size(); ++i) {
if (small_size_blocks_[i] != nullptr && size <= kSmallSizes[i]) {

Просмотреть файл

@ -1,14 +0,0 @@
diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
index f7b64a080..3493d9082 100644
--- a/src/google/protobuf/port_def.inc
+++ b/src/google/protobuf/port_def.inc
@@ -564,7 +564,8 @@
// Our use of constinit does not yet work with GCC:
// https://github.com/protocolbuffers/protobuf/issues/8310
-#if defined(__cpp_constinit) && !defined(__GNUC__)
+// Does not work yet with Visual Studio 2019 Update 16.10
+#if defined(__cpp_constinit) && !defined(__GNUC__) && !defined(_MSC_VER)
#define PROTOBUF_CONSTINIT constinit
#elif defined(__has_cpp_attribute)
#if __has_cpp_attribute(clang::require_constant_initialization)

Просмотреть файл

@ -1,13 +1,13 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO protocolbuffers/protobuf
REF 436bd7880e458532901c58f4d9d1ea23fa7edd52 #v3.15.8
SHA512 88bb9a965bccfe11a07aee2c0c16eb9cc1845ea2d7500ef6def3e1c0a8155ac4eadd0ceef4b12552960dffe95a0fc82549d1abba71ca073ab86ec5de57d9cafb
REF v3.18.0
SHA512 2c8ff451b54120e4670f7ea8c92c0c7d70f4bb781979f74f59ddcb7c9cc74fe3e8910fc579d2686fb0e1aafa35fb9548ccab667accf2358c71cfd17ba38d7826
HEAD_REF master
PATCHES
fix-static-build.patch
fix-default-proto-file-path.patch
port_def.patch
fix-uwp-build.patch
)
string(COMPARE EQUAL "${TARGET_TRIPLET}" "${HOST_TRIPLET}" protobuf_BUILD_PROTOC_BINARIES)
@ -79,7 +79,7 @@ if(protobuf_BUILD_PROTOC_BINARIES)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_copy_tools(TOOL_NAMES protoc AUTO_CLEAN)
else()
vcpkg_copy_tools(TOOL_NAMES protoc protoc-3.15.8.0 AUTO_CLEAN)
vcpkg_copy_tools(TOOL_NAMES protoc protoc-3.18.0.0 AUTO_CLEAN)
endif()
else()
file(COPY ${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT} DESTINATION ${CURRENT_PACKAGES_DIR}/tools)

Просмотреть файл

@ -1,7 +1,6 @@
{
"name": "protobuf",
"version-semver": "3.15.8",
"port-version": 4,
"version-semver": "3.18.0",
"description": "Protocol Buffers - Google's data interchange format",
"homepage": "https://github.com/protocolbuffers/protobuf",
"dependencies": [

Просмотреть файл

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "0aeec8ed7245362e90ef531d8ecaf4ca315e85e5",
"version-semver": "4.10.0",
"port-version": 1
},
{
"git-tree": "76f86c7d5993d59f58a0863b9e2ca439db88efba",
"version-semver": "4.10.0",

Просмотреть файл

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "0b89b1bee5f50f8bdb551ae2373feb51b144fbc2",
"version-string": "0.9.7",
"port-version": 2
},
{
"git-tree": "8d3ba620eff30244f2ca27af0814f78ce9049308",
"version-string": "0.9.7",

Просмотреть файл

@ -122,7 +122,7 @@
},
"arcus": {
"baseline": "4.10.0",
"port-version": 0
"port-version": 1
},
"argagg": {
"baseline": "0.4.6",
@ -1118,7 +1118,7 @@
},
"brpc": {
"baseline": "0.9.7",
"port-version": 1
"port-version": 2
},
"brunocodutra-metal": {
"baseline": "2.1.1",
@ -1174,7 +1174,7 @@
},
"caffe2": {
"baseline": "0.8.1",
"port-version": 4
"port-version": 5
},
"cairo": {
"baseline": "1.17.4",
@ -4766,7 +4766,7 @@
},
"opencv4": {
"baseline": "4.5.3",
"port-version": 1
"port-version": 2
},
"opendnp3": {
"baseline": "3.1.0",
@ -5221,8 +5221,8 @@
"port-version": 0
},
"protobuf": {
"baseline": "3.15.8",
"port-version": 4
"baseline": "3.18.0",
"port-version": 0
},
"protobuf-c": {
"baseline": "1.3.2",

Просмотреть файл

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "e4ebcedb57e572959c4f8e30c2885cda2367e0a7",
"version-string": "0.8.1",
"port-version": 5
},
{
"git-tree": "e50097be149d80e1397e95280aecd5160961d286",
"version-string": "0.8.1",

Просмотреть файл

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "6b5539ab3cd468944f8d46698c610285319bf0f7",
"version": "4.5.3",
"port-version": 2
},
{
"git-tree": "9d18da7f0c17619f7912a5d53b0316c7a18d625a",
"version": "4.5.3",

Просмотреть файл

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "19c2bf45c235e6126161bae36aa7ff7e1fcda479",
"version-semver": "3.18.0",
"port-version": 0
},
{
"git-tree": "6204194eaf9d8ff0fe78d498f77fee57cd19ce59",
"version-semver": "3.15.8",