Accepting request 1096499 from devel:tools:building

- update to 23.3:
  C++
  * Regenerate stale files
  * Use the same ABI for static and shared libraries on non-
    Windows platforms
  * Add a workaround for GCC constexpr bug
  Objective-C
  * Regenerate stale files
  UPB (Python/PHP/Ruby C-Extension)
  * Fixed a bug in `upb_Map_Delete()` that caused crashes in
    map.delete(k) for Ruby when string-keyed maps were in use.
  Compiler
  * Add missing header to Objective-c generator
  * Add a workaround for GCC constexpr bug
  Java
  * Rollback of: Simplify protobuf Java message builder by
    removing methods that calls the super class only.
  Csharp
  * [C#] Replace regex that validates descriptor names
- drop 0001-Use-the-same-ABI-for-static-and-shared-libraries-on-.patch (upstream)

OBS-URL: https://build.opensuse.org/request/show/1096499
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/protobuf?expand=0&rev=74
This commit is contained in:
Dominique Leuenberger 2023-07-04 13:21:41 +00:00 committed by Git OBS Bridge
commit 74a62f39f8
6 changed files with 47 additions and 91 deletions

View File

@ -1,71 +0,0 @@
From 9820a511465c6f31a19bb3cad276e680ed9f2ee9 Mon Sep 17 00:00:00 2001
From: "Romain Geissler @ Amadeus" <romain.geissler@amadeus.com>
Date: Tue, 6 Jun 2023 10:49:55 -0700
Subject: [PATCH] Use the same ABI for static and shared libraries on
non-Windows platforms (#12983)
Hi,
It seems that until last year, the logic behind `PROTOBUF_USE_DLLS` was for Windows (MSCV) only. It was changed to all platforms here in https://github.com/protocolbuffers/protobuf/commit/5a0887fc6529596eff5c0f72febc602a9d494cc2
Last month, the generated pkg config files were updated to reflect the protobuf build-time value of `PROTOBUF_USE_DLLS` as it was indeed noted that it changes the ABI. This was done in https://github.com/protocolbuffers/protobuf/pull/12700 In the commit message it is mentionned that most likely we shall rather have a stable ABI.
Finally in https://github.com/protocolbuffers/protobuf/issues/12746 which at some point mentions https://issuetracker.google.com/issues/283987730#comment7 where a Google employee hits the linker issue:
```
undefined reference to `google::protobuf::internal::ThreadSafeArena::thread_cache_'
```
which denotes a mix of some .o or libs built `PROTOBUF_USE_DLLS` defined and some others build with `PROTOBUF_USE_DLLS` undefined, resulting in ABI incompatibilities.
I also hit this issue while trying to include protobuf in a corporate environment using it's own proprietary build system in which it is expected that .a and .so use a compatible ABI.
From my own understanding, ideally we should always use `thread_local` variables, but experience has shown that:
- old iOS (iOS < 9) didn't seem to accept `thread_local`, leading to the `GOOGLE_PROTOBUF_NO_THREADLOCAL` macro later renamed `PROTOBUF_NO_THREADLOCAL` which allowed to disable this, but it is not set anywhere in the protobuf code base. Also I doubt you still want to support such old iOS now, so maybe you should consider removing all `PROTOBUF_NO_THREADLOCAL` related code paths (this pull request doesn't do this).
- MSVC's DLL interface doesn't seem to accept exporting thread local variables (at least from what I understood, I know absolutely nothing about the Windows ecosystem), yet we can "hide" a thread local variable in a static function using a thread local variable. However in that case the access to TLS variable is not inlined, leading to worse performances, this hack shall be done only for Windows (actually when using MSVC) *AND* we build a shared library.
- In all other cases, a classical `thread_local` shall be used, no matter if we build a static or a shared library. In particular on Linux which I guess is the target Google cares the more about for its own production. This pull request achieves this.
Am I right in my conclusion ?
Closes #12983
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/12983 from Romain-Geissler-1A:stable-abi-use-dll-non-windows dc23ff50f67cf0c8e45900a78700d1fc3e8bec39
PiperOrigin-RevId: 538230923
(cherry picked from commit 4329fde9cf3fab7d1b3a9abe0fbeee1ad8a8b111)
---
src/google/protobuf/arena.cc | 2 +-
src/google/protobuf/thread_safe_arena.h | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc
index 071360f14..0e4f12140 100644
--- a/src/google/protobuf/arena.cc
+++ b/src/google/protobuf/arena.cc
@@ -493,7 +493,7 @@ ThreadSafeArena::ThreadCache& ThreadSafeArena::thread_cache() {
new internal::ThreadLocalStorage<ThreadCache>();
return *thread_cache_->Get();
}
-#elif defined(PROTOBUF_USE_DLLS)
+#elif defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)
ThreadSafeArena::ThreadCache& ThreadSafeArena::thread_cache() {
static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache;
return thread_cache;
diff --git a/src/google/protobuf/thread_safe_arena.h b/src/google/protobuf/thread_safe_arena.h
index d2a3e6e72..bcb9869d5 100644
--- a/src/google/protobuf/thread_safe_arena.h
+++ b/src/google/protobuf/thread_safe_arena.h
@@ -257,9 +257,9 @@ class PROTOBUF_EXPORT ThreadSafeArena {
// iOS does not support __thread keyword so we use a custom thread local
// storage class we implemented.
static ThreadCache& thread_cache();
-#elif defined(PROTOBUF_USE_DLLS)
- // Thread local variables cannot be exposed through DLL interface but we can
- // wrap them in static functions.
+#elif defined(PROTOBUF_USE_DLLS) && defined(_MSC_VER)
+ // Thread local variables cannot be exposed through MSVC DLL interface but we
+ // can wrap them in static functions.
static ThreadCache& thread_cache();
#else
PROTOBUF_CONSTINIT static PROTOBUF_THREAD_LOCAL ThreadCache thread_cache_;
--
2.41.0

View File

@ -1,3 +1,3 @@
libprotobuf22_5_0
libprotoc22_5_0
libprotobuf-lite22_5_0
libprotobuf23_3_0
libprotoc23_3_0
libprotobuf-lite23_3_0

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4b98c800b352e7582bc92ed398999030ce4ebb49c7858dcb070850ec476b72f2
size 4924661

3
protobuf-23.3.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4e176116949be52b0408dfd24f8925d1eb674a781ae242a75296b17a1c721395
size 5043803

View File

@ -1,3 +1,31 @@
-------------------------------------------------------------------
Mon Jul 3 07:58:43 UTC 2023 - Dirk Müller <dmueller@suse.com>
- update to 23.3:
C++
* Regenerate stale files
* Use the same ABI for static and shared libraries on non-
Windows platforms
* Add a workaround for GCC constexpr bug
Objective-C
* Regenerate stale files
UPB (Python/PHP/Ruby C-Extension)
* Fixed a bug in `upb_Map_Delete()` that caused crashes in
map.delete(k) for Ruby when string-keyed maps were in use.
Compiler
* Add missing header to Objective-c generator
* Add a workaround for GCC constexpr bug
Java
* Rollback of: Simplify protobuf Java message builder by
removing methods that calls the super class only.
Csharp
* [C#] Replace regex that validates descriptor names
- drop 0001-Use-the-same-ABI-for-static-and-shared-libraries-on-.patch (upstream)
-------------------------------------------------------------------
Wed Jun 14 08:32:55 UTC 2023 - Fabian Vogt <fvogt@suse.com>

View File

@ -25,10 +25,8 @@
%bcond_without java
%bcond_without python3
Name: protobuf
Version: 22.5
# python module have their own version specified in python/google/protobuf/__init__.py
%global gversion 22.5
%global sover 22_5_0
Version: 23.3
%global sover 23_3_0
Release: 0
Summary: Protocol Buffers - Google's data interchange format
License: BSD-3-Clause
@ -39,8 +37,6 @@ Source1: manifest.txt.in
Source2: baselibs.conf
Source1000: %{name}-rpmlintrc
Patch0: add-missing-stdint-header.patch
# PATCH-FIX-UPSTREAM https://github.com/protocolbuffers/protobuf/commit/4329fde9cf3fab7d1b3a9abe0fbeee1ad8a8b111
Patch1: 0001-Use-the-same-ABI-for-static-and-shared-libraries-on-.patch
BuildRequires: %{python_module abseil}
BuildRequires: %{python_module devel}
BuildRequires: %{python_module python-dateutil}
@ -107,12 +103,12 @@ Summary: Header files, libraries and development documentation for %{name
Group: Development/Libraries/C and C++
Requires: abseil-cpp-devel >= 20230125
Requires: gcc-c++
Requires: libprotobuf%{sover} = %{gversion}
Requires: libprotobuf%{sover} = %{VERSION}
Requires: libprotobuf-lite%{sover}
Requires: pkgconfig(zlib)
Conflicts: protobuf2-devel
Conflicts: protobuf21-devel
Provides: libprotobuf-devel = %{gversion}
Provides: libprotobuf-devel = %{VERSION}
%description devel
Protocol Buffers are a way of encoding structured data in an efficient yet
@ -121,7 +117,7 @@ RPC protocols and file formats.
%if 0%{?python_subpackage_only}
%package -n python-%{name}
Version: 4.%{gversion}
Version: 4.%{VERSION}
Summary: Python Bindings for Google Protocol Buffers
Group: Development/Libraries/Python
@ -131,7 +127,7 @@ This package contains the Python bindings for Google Protocol Buffers.
%else
%package -n python3-%{name}
Version: 4.%{gversion}
Version: 4.%{VERSION}
Summary: Python3 Bindings for Google Protocol Buffers
Group: Development/Libraries/Python
@ -148,7 +144,10 @@ Requires: java >= 1.6.0
This package contains the Java bindings for Google Protocol Buffers.
%prep
%autosetup -p1 -n %{tarname}-%{gversion}
%autosetup -p1 -n %{tarname}-%{VERSION}
# python module have their own version specified in python/google/protobuf/__init__.py
grep -qF "'4.%{VERSION}'" python/google/protobuf/__init__.py
# The previous blank line is crucial for older system being able
# to use the autosetup macro
@ -226,13 +225,13 @@ popd
%files -n libprotobuf%{sover}
%license LICENSE
%{_libdir}/libprotobuf.so.%{gversion}.0
%{_libdir}/libprotobuf.so.%{VERSION}.0
%files -n libprotoc%{sover}
%{_libdir}/libprotoc.so.%{gversion}.0
%{_libdir}/libprotoc.so.%{VERSION}.0
%files -n libprotobuf-lite%{sover}
%{_libdir}/libprotobuf-lite.so.%{gversion}.0
%{_libdir}/libprotobuf-lite.so.%{VERSION}.0
%files devel
%doc CONTRIBUTORS.txt README.md