From 7440e97ce677979db7f4a005965a3b13dc8fbaf7 Mon Sep 17 00:00:00 2001 From: Oliver Eikemeier Date: Fri, 11 Jun 2021 16:33:22 +0200 Subject: [PATCH] Cherry-Pick protocolbuffers/protobuf#8714 Signed-off-by: Oliver Eikemeier --- .gitattributes | 1 + README.adoc | 17 ----------------- WORKSPACE | 1 + patches/8714.patch | 39 +++++++++++++++++++++++++++++++++++++++ patches/BUILD | 0 5 files changed, 41 insertions(+), 17 deletions(-) create mode 100644 patches/8714.patch create mode 100644 patches/BUILD diff --git a/.gitattributes b/.gitattributes index 6090cf5..b2f4d02 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,6 +3,7 @@ *.bzl text *.java text *.json text +*.patch text *.proto text *.yaml text BUILD text diff --git a/README.adoc b/README.adoc index 3936a03..aa8597a 100644 --- a/README.adoc +++ b/README.adoc @@ -185,20 +185,3 @@ data model naming conventions. MapStruct uses a fixed und quite unflexible acces so you can't really decide that protocol buffers should have one convention but Immutables another. Especially for Immutables we are forced to use JavaBeans-style naming convention, although this is not a JEE application. - -== Known Issues - -Warning during build: -[subs="+quotes"] ----- -[lime]#INFO:# From Compiling src/google/protobuf/descriptor.cc: -*external/com_google_protobuf/src/google/protobuf/descriptor.cc:1038:9: [fuchsia]#warning:# passing variable 'unknown_enum_values_by_number_' by reference requires holding mutex 'unknown_enum_values_mu_' [-Wthread-safety-reference]* - unknown_enum_values_by_number_, std::make_pair(parent, number)); - [lime]#^# -*external/com_google_protobuf/src/google/protobuf/descriptor.cc:1048:9: [fuchsia]#warning:# passing variable 'unknown_enum_values_by_number_' by reference requires holding mutex 'unknown_enum_values_mu_' [-Wthread-safety-reference]* - unknown_enum_values_by_number_, std::make_pair(parent, number)); - [lime]#^# -2 warnings generated. ----- - -Fixed in https://github.com/protocolbuffers/protobuf/pull/8714[GitHub pull request #8714]. diff --git a/WORKSPACE b/WORKSPACE index 7e3ebbd..7f22c86 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -29,6 +29,7 @@ http_archive( http_archive( name = "com_google_protobuf", + patches = ["//patches:8714.patch"], sha256 = "c6003e1d2e7fefa78a3039f19f383b4f3a61e81be8c19356f85b6461998ad3db", strip_prefix = "protobuf-3.17.3", urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.17.3.tar.gz"], diff --git a/patches/8714.patch b/patches/8714.patch new file mode 100644 index 0000000..ecadeaf --- /dev/null +++ b/patches/8714.patch @@ -0,0 +1,39 @@ +https://github.com/protocolbuffers/protobuf/pull/8714 +--- + src/google/protobuf/stubs/mutex.h | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +diff --git src/google/protobuf/stubs/mutex.h src/google/protobuf/stubs/mutex.h +index 79c9f6784..5c025b149 100644 +--- src/google/protobuf/stubs/mutex.h ++++ src/google/protobuf/stubs/mutex.h +@@ -52,10 +52,12 @@ + __attribute__((acquire_capability(__VA_ARGS__))) + #define GOOGLE_PROTOBUF_RELEASE(...) \ + __attribute__((release_capability(__VA_ARGS__))) ++#define GOOGLE_PROTOBUF_SCOPED_CAPABILITY __attribute__((scoped_lockable)) + #define GOOGLE_PROTOBUF_CAPABILITY(x) __attribute__((capability(x))) + #else + #define GOOGLE_PROTOBUF_ACQUIRE(...) + #define GOOGLE_PROTOBUF_RELEASE(...) ++#define GOOGLE_PROTOBUF_SCOPED_CAPABILITY + #define GOOGLE_PROTOBUF_CAPABILITY(x) + #endif + +@@ -140,10 +142,12 @@ class GOOGLE_PROTOBUF_CAPABILITY("mutex") PROTOBUF_EXPORT WrappedMutex { + using Mutex = WrappedMutex; + + // MutexLock(mu) acquires mu when constructed and releases it when destroyed. +-class PROTOBUF_EXPORT MutexLock { ++class GOOGLE_PROTOBUF_SCOPED_CAPABILITY PROTOBUF_EXPORT MutexLock { + public: +- explicit MutexLock(Mutex *mu) : mu_(mu) { this->mu_->Lock(); } +- ~MutexLock() { this->mu_->Unlock(); } ++ explicit MutexLock(Mutex *mu) GOOGLE_PROTOBUF_ACQUIRE(mu) : mu_(mu) { ++ this->mu_->Lock(); ++ } ++ ~MutexLock() GOOGLE_PROTOBUF_RELEASE() { this->mu_->Unlock(); } + private: + Mutex *const mu_; + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLock); +-- diff --git a/patches/BUILD b/patches/BUILD new file mode 100644 index 0000000..e69de29