Source: process-cpp
Version: 3.0.1-8
Severity: normal
Tags: ftbfs patch upstream
User: debian-ri...@lists.debian.org
Usertags: riscv64

Hi,

process-cpp fails to build on riscv64 with the following failure:

| Linking CXX shared library libprocess-cpp.so
| cd /<<PKGBUILDDIR>>/obj-riscv64-linux-gnu/src && /usr/bin/cmake -E 
cmake_link_script CMakeFiles/process-cpp.dir/link.txt --verbose=1
| /usr/bin/c++ -fPIC -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
-D_FORTIFY_SOURCE=2 -std=c++11 -Wall -fno-strict-aliasing -fvisibility=hidden 
-fvisibility-inlines-hidden -pedantic -Wextra -Werror -Wno-error=format  
-Wl,--version-script,/<<PKGBUILDDIR>>/symbols.map -Wl,-z,relro 
-Wl,--no-undefined -shared -Wl,-soname,libprocess-cpp.so.3 -o 
libprocess-cpp.so.3.0.0 CMakeFiles/process-cpp.dir/core/posix/backtrace.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/child_process.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/exec.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/fork.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/process.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/process_group.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/signal.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/signalable.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/standard_stream.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/wait.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/this_process.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/linux/proc/process/oom_adj.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/linux/proc/process/oom_score.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/linux/proc/process/oom_score_adj.cpp.o 
CMakeFiles/process-cpp.dir/core/posix/linux/proc/process/stat.cpp.o 
CMakeFiles/process-cpp.dir/core/testing/cross_process_sync.cpp.o 
CMakeFiles/process-cpp.dir/core/testing/fork_and_run.cpp.o  
/usr/lib/riscv64-linux-gnu/libboost_iostreams.so.1.74.0 
/usr/lib/riscv64-linux-gnu/libboost_system.so.1.74.0 -lpthread 
| /usr/bin/ld: CMakeFiles/process-cpp.dir/core/posix/child_process.cpp.o: in 
function `.L0 ':
| /usr/include/riscv64-linux-gnu/c++/11/bits/gthr-default.h:778: undefined 
reference to `__atomic_exchange_1'
| collect2: error: ld returned 1 exit status

The full build log is available there:
https://buildd.debian.org/status/fetch.php?pkg=process-cpp&arch=riscv64&ver=3.0.1-8&stamp=1639996742&raw=0

The problem is that the linking is not done correctly, it uses -lpthread
meaning linking with the pthread library, instead of -pthread which
means enable thread support, and which brings libatomic.so on riscv64.
This can be fixed by using the THREADS_PREFER_PTHREAD_FLAG option, which
is "highly recommended" according to the documentation, but
unfortunately not the default.

This is what the attached patch does, could you please include it in the
next upload?

Thanks,
Aurelien
--- process-cpp-3.0.1/debian/patches/0003-link-pthread.patch
+++ process-cpp-3.0.1/debian/patches/0003-link-pthread.patch
@@ -0,0 +1,19 @@
+Description: Link with -pthread instead of -lpthread
+ The canonical way to link with the thread library is to use -pthread, which
+ brings in additional libraries like libatomic.so on riscv64. However cmake
+ defaults to link with -lpthread which only bring the libpthread.so library.
+ Fortunately it has the option THREADS_PREFER_PTHREAD_FLAG for that, which is
+ "highly recommended" but not the default.
+Author: Aurelien Jarno <aure...@debian.org>
+Last-Update: 2021-12-20
+
+--- process-cpp-3.0.1.orig/CMakeLists.txt
++++ process-cpp-3.0.1/CMakeLists.txt
+@@ -20,6 +20,7 @@ project(process-cpp)
+ 
+ find_package(Boost COMPONENTS iostreams system REQUIRED)
+ find_package(PkgConfig REQUIRED)
++set(THREADS_PREFER_PTHREAD_FLAG ON)
+ find_package(Threads REQUIRED)
+ 
+ pkg_check_modules(PROPERTIES_CPP properties-cpp)
--- process-cpp-3.0.1/debian/patches/series
+++ process-cpp-3.0.1/debian/patches/series
@@ -1,2 +1,3 @@
 0001-Don-t-run-tests.patch
 0002-Reproducible-documentation.patch
+0003-link-pthread.patch

Reply via email to