Skip to content

Commit

Permalink
Merge pull request #10273 from acozzette/cherrypicks
Browse files Browse the repository at this point in the history
Cherry-pick fixes for upcoming 21.3 release
  • Loading branch information
acozzette committed Jul 19, 2022
2 parents 3f09570 + d41d498 commit c415126
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 13 deletions.
21 changes: 21 additions & 0 deletions 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)
Expand Down
1 change: 1 addition & 0 deletions Protobuf-C++.podspec
Expand Up @@ -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
4 changes: 2 additions & 2 deletions protobuf_deps.bzl
Expand Up @@ -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"
)
8 changes: 2 additions & 6 deletions src/google/protobuf/message_lite.cc
Expand Up @@ -520,18 +520,14 @@ void GenericTypeHandler<std::string>::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<Arena*>(ptr_ - kMessageOwnedArenaTagMask);
}
}
#endif

// Non-inline variants of std::string specializations for
// various InternalMetadata routines.
Expand Down
13 changes: 10 additions & 3 deletions src/google/protobuf/metadata_lite.h
Expand Up @@ -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<Arena*>(ptr_ - kMessageOwnedArenaTagMask);
}
}
#else
~InternalMetadata();
CheckedDestruct();
#endif
}

template <typename T>
void Delete() {
Expand Down Expand Up @@ -261,6 +265,9 @@ class PROTOBUF_EXPORT InternalMetadata {
PROTOBUF_NOINLINE void DoSwap(T* other) {
mutable_unknown_fields<T>()->Swap(other);
}

// Private helper with debug checks for ~InternalMetadata()
void CheckedDestruct();
};

// String Template specializations.
Expand Down
9 changes: 7 additions & 2 deletions src/google/protobuf/port_def.inc
Expand Up @@ -638,21 +638,26 @@
#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]]
#define PROTOBUF_CONSTEXPR constexpr
#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
Expand Down

0 comments on commit c415126

Please sign in to comment.