diff --git a/CHANGES.txt b/CHANGES.txt index 6da3dbd1cb2f..05677842fbd1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,24 @@ +2022-07-19 version 21.3 (C++/Java/Python/PHP/Objective-C/C#/Ruby) + C++ + * Add header search paths to Protobuf-C++.podspec (#10024) + * Fixed Visual Studio constinit errors (#10232) + * Fix #9947: make the ABI compatible between debug and non-debug builds (#10271) + + UPB + * Allow empty package names (fixes behavior regression in 4.21.0) + * Fix a SEGV bug when comparing a non-materialized sub-message (#10208) + * Fix several bugs in descriptor mapping containers (eg. descriptor.services_by_name) + * for x in mapping now yields keys rather than values, to match Python conventions and the behavior of the old library. + * Lookup operations now correctly reject unhashable types as map keys. + * We implement repr() to use the same format as dict. + * Fix maps to use the ScalarMapContainer class when appropriate + + PHP + * Add "readonly" as a keyword for PHP and add previous classnames to descriptor pool (#10041) + + Python + * Make //:protobuf_python and //:well_known_types_py_pb2 public (#10118) + 2022-06-27 version 21.2 (C++/Java/Python/PHP/Objective-C/C#/Ruby) C++ * ArenaString improvements (fix alignment issue) diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec index e34d3430dec2..c8a516bb0563 100644 --- a/Protobuf-C++.podspec +++ b/Protobuf-C++.podspec @@ -35,6 +35,7 @@ Pod::Spec.new do |s| # Do not let src/google/protobuf/stubs/time.h override system API 'USE_HEADERMAP' => 'NO', 'ALWAYS_SEARCH_USER_PATHS' => 'NO', + 'HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)/src"' } end diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index 05d5fc25a6a6..66a19013e95c 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -114,6 +114,6 @@ def protobuf_deps(): _github_archive( name = "upb", repo = "https://github.com/protocolbuffers/upb", - commit = "553fd5c2a77aefd4ef565e339efa8b828b8d078e", - sha256 = "6d7e139f2359104f960e045690cf1e326efd1ef3de51aa08362ecd27e1d25636" + commit = "dad71550bdf01fd057c9e284fb73c5ffc8098984", + sha256 = "47b0c810b5830cd7fe7388b4f540d6d25fe4e511beb3412e1f92e21079b48dec" ) diff --git a/src/google/protobuf/message_lite.cc b/src/google/protobuf/message_lite.cc index 3a1b67bf66af..da66c1965b4c 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 11faba69fca6..0c31517f08af 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. diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 8858e1936826..10005bf46526 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -638,14 +638,15 @@ #ifdef PROTOBUF_CONSTINIT #error PROTOBUF_CONSTINIT was previously defined #endif -#if defined(__cpp_constinit) +#if defined(__cpp_constinit) && !defined(_MSC_VER) #define PROTOBUF_CONSTINIT constinit #define PROTOBUF_CONSTEXPR constexpr // Some older Clang versions incorrectly raise an error about // constant-initializing weak default instance pointers. Versions 12.0 and // higher seem to work, except that XCode 12.5.1 shows the error even though it // uses Clang 12.0.5. -#elif __has_cpp_attribute(clang::require_constant_initialization) && \ +// Clang-cl on Windows raises error also. +#elif !defined(_MSC_VER) && __has_cpp_attribute(clang::require_constant_initialization) && \ ((defined(__APPLE__) && __clang_major__ >= 13) || \ (!defined(__APPLE__) && __clang_major__ >= 12)) #define PROTOBUF_CONSTINIT [[clang::require_constant_initialization]] @@ -653,6 +654,10 @@ #elif PROTOBUF_GNUC_MIN(12, 2) #define PROTOBUF_CONSTINIT __constinit #define PROTOBUF_CONSTEXPR constexpr +// MSVC 17 currently seems to raise an error about constant-initialized pointers. +#elif defined(_MSC_VER) && _MSC_VER >= 1930 +#define PROTOBUF_CONSTINIT +#define PROTOBUF_CONSTEXPR constexpr #else #define PROTOBUF_CONSTINIT #define PROTOBUF_CONSTEXPR