diff --git a/contrib/depends/packages/protobuf.mk b/contrib/depends/packages/protobuf.mk index 3fd9a89..19c6b27 100644 --- a/contrib/depends/packages/protobuf.mk +++ b/contrib/depends/packages/protobuf.mk @@ -5,12 +5,17 @@ $(package)_file_name=$(native_$(package)_file_name) $(package)_sha256_hash=$(native_$(package)_sha256_hash) $(package)_dependencies=native_$(package) $(package)_cxxflags=-std=c++11 +$(package)_patches = fix-abi.patch define $(package)_set_vars $(package)_config_opts=--disable-shared --with-protoc=$(build_prefix)/bin/protoc $(package)_config_opts_linux=--with-pic endef +define $(package)_preprocess_cmds + patch -p1 -i $($(package)_patch_dir)/fix-abi.patch +endef + define $(package)_config_cmds cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . && \ cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub ./third_party/googletest/googletest/build-aux/ && \ diff --git a/contrib/depends/patches/protobuf/fix-abi.patch b/contrib/depends/patches/protobuf/fix-abi.patch new file mode 100644 index 0000000..ad5829d --- /dev/null +++ b/contrib/depends/patches/protobuf/fix-abi.patch @@ -0,0 +1,75 @@ +From 101b6199f33a396b5758057ca10b8f9c8d8e8855 Mon Sep 17 00:00:00 2001 +From: Antoine Pitrou +Date: Tue, 19 Jul 2022 16:40:28 +0200 +Subject: [PATCH] Fix #9947: make the ABI identical between debug and non-debug + builds + +--- + src/google/protobuf/message_lite.cc | 8 ++------ + src/google/protobuf/metadata_lite.h | 13 ++++++++++--- + 2 files changed, 12 insertions(+), 9 deletions(-) + +diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc +index 3a1b67bf6..da66c1965 100644 +--- a/src/google/protobuf/message_lite.cc ++++ b/src/google/protobuf/message_lite.cc +@@ -520,18 +520,14 @@ void GenericTypeHandler::Merge(const std::string& from, + *to = from; + } + +-// Non-inline implementations of InternalMetadata routines +-#if defined(NDEBUG) || defined(_MSC_VER) +-// for opt and MSVC builds, the destructor is defined in the header. +-#else ++// Non-inline implementations of InternalMetadata destructor + // This is moved out of the header because the GOOGLE_DCHECK produces a lot of code. +-InternalMetadata::~InternalMetadata() { ++void InternalMetadata::CheckedDestruct() { + if (HasMessageOwnedArenaTag()) { + GOOGLE_DCHECK(!HasUnknownFieldsTag()); + delete reinterpret_cast(ptr_ - kMessageOwnedArenaTagMask); + } + } +-#endif + + // Non-inline variants of std::string specializations for + // various InternalMetadata routines. +diff --git a/src/google/protobuf/metadata_lite.h b/src/google/protobuf/metadata_lite.h +index 11faba69f..0c31517f0 100644 +--- a/src/google/protobuf/metadata_lite.h ++++ b/src/google/protobuf/metadata_lite.h +@@ -74,15 +74,19 @@ class PROTOBUF_EXPORT InternalMetadata { + GOOGLE_DCHECK(!is_message_owned || arena != nullptr); + } + +-#if defined(NDEBUG) || defined(_MSC_VER) ++ // To keep the ABI identical between debug and non-debug builds, ++ // the destructor is always defined here even though it may delegate ++ // to a non-inline private method. ++ // (see https://github.com/protocolbuffers/protobuf/issues/9947) + ~InternalMetadata() { ++#if defined(NDEBUG) || defined(_MSC_VER) + if (HasMessageOwnedArenaTag()) { + delete reinterpret_cast(ptr_ - kMessageOwnedArenaTagMask); + } +- } + #else +- ~InternalMetadata(); ++ CheckedDestruct(); + #endif ++ } + + template + void Delete() { +@@ -261,6 +265,9 @@ class PROTOBUF_EXPORT InternalMetadata { + PROTOBUF_NOINLINE void DoSwap(T* other) { + mutable_unknown_fields()->Swap(other); + } ++ ++ // Private helper with debug checks for ~InternalMetadata() ++ void CheckedDestruct(); + }; + + // String Template specializations. +-- +2.40.1