Source: protobuf Version: 3.0.0-3 Severity: serious Tags: patch upstream [I have added a Cc: to the debian-s390 list as it appears we have multiple copies of this code in the archive, so the patch might be useful in other packages.]
Dear Maintainer, The new version of protobuf fails to build on s390x with the following error: | /bin/bash ../libtool --tag=CXX --mode=link g++ -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -g -O2 -fdebug-prefix-map=/«PKGBUILDDIR»=. -fstack-protector-strong -Wformat -Werror=format-security -pthread -Wl,-z,relro -o protoc google/protobuf/compiler/main.o -lpthread libprotobuf.la libprotoc.la -lz | libtool: link: g++ -pthread -DHAVE_PTHREAD=1 -DHAVE_ZLIB=1 -Wall -Wno-sign-compare -g -O2 -fdebug-prefix-map=/«PKGBUILDDIR»=. -fstack-protector-strong -Wformat -Werror=format-security -pthread -Wl,-z -Wl,relro -o .libs/protoc google/protobuf/compiler/main.o -lpthread ./.libs/libprotobuf.so ./.libs/libprotoc.so -lz -pthread | ./.libs/libprotobuf.so: undefined reference to `google::protobuf::internal::NoBarrier_AtomicIncrement(long volatile*, long)' | ./.libs/libprotobuf.so: undefined reference to `google::protobuf::internal::NoBarrier_Store(long volatile*, long)' | ./.libs/libprotobuf.so: undefined reference to `google::protobuf::internal::NoBarrier_AtomicExchange(long volatile*, long)' | ./.libs/libprotobuf.so: undefined reference to `google::protobuf::internal::NoBarrier_Load(long const volatile*)' | collect2: error: ld returned 1 exit status | Makefile:3389: recipe for target 'protoc' failed | make[4]: *** [protoc] Error 1 | make[4]: Leaving directory '/«PKGBUILDDIR»/src' | Makefile:1259: recipe for target 'all-recursive' failed Here is the full build log: https://buildd.debian.org/status/fetch.php?pkg=protobuf&arch=s390x&ver=3.0.0-3&stamp=1472017457 s390x uses the generic atomics based on GCC atomics builtins, and some of 64-bit atomics functions haven't been implemented yet. The patch below fixes the problem. With it protobuf builds on s390x and the testsuite passes successfully. Thanks for considering, Aurelien --- protobuf-3.0.0.orig/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h +++ protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h @@ -128,6 +128,45 @@ inline Atomic64 NoBarrier_CompareAndSwap return old_value; } +inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, + Atomic64 new_value) { + return __atomic_exchange_n(ptr, new_value, __ATOMIC_RELAXED); +} + +inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, + Atomic64 increment) { + return __atomic_add_fetch(ptr, increment, __ATOMIC_RELAXED); +} + +inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, + Atomic64 increment) { + return __atomic_add_fetch(ptr, increment, __ATOMIC_SEQ_CST); +} + +inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr, + Atomic64 old_value, + Atomic64 new_value) { + __atomic_compare_exchange_n(ptr, &old_value, new_value, true, + __ATOMIC_RELEASE, __ATOMIC_ACQUIRE); + return old_value; +} + +inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) { + __atomic_store_n(ptr, value, __ATOMIC_RELAXED); +} + +inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) { + __atomic_store_n(ptr, value, __ATOMIC_SEQ_CST); +} + +inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) { + return __atomic_load_n(ptr, __ATOMIC_RELAXED); +} + +inline Atomic64 Release_Load(volatile const Atomic64* ptr) { + return __atomic_load_n(ptr, __ATOMIC_SEQ_CST); +} + #endif // defined(__LP64__) } // namespace internal -- System Information: Debian Release: stretch/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable') Architecture: s390x Kernel: Linux 4.6.0-1-s390x (SMP w/1 CPU core) Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system)