Bug#978632: ddnet: FTBFS on riscv64, linked with -lpthread instead of -pthread
Aurelien Jarno
aurel32 at debian.org
Tue Dec 29 12:39:14 GMT 2020
Source: ddnet
Version: 15.1.3-1
Severity: normal
Tags: ftbfs patch upstream
User: debian-riscv at lists.debian.org
Usertags: riscv64
Hi,
ddnet fails to build on riscv64 with the following failure:
| /usr/bin/ld: CMakeFiles/DDNet-Server.dir/src/engine/server/databases/mysql.cpp.o: in function `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag)':
| /usr/include/c++/10/bits/basic_string.tcc:219: undefined reference to `__atomic_exchange_1'
| /usr/bin/ld: CMakeFiles/DDNet-Server.dir/src/engine/server/databases/sqlite.cpp.o: in function `CSqliteConnection::ExceptionOnError(int)':
| ./obj-riscv64-linux-gnu/./src/engine/server/databases/sqlite.cpp:233: 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=ddnet&arch=riscv64&ver=15.1.3-1&stamp=1602996432&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
-------------- next part --------------
--- ddnet-15.1.3/debian/patches/link-pthread.patch 1970-01-01 01:00:00.000000000 +0100
+++ ddnet-15.1.3/debian/patches/link-pthread.patch 2020-12-28 17:58:30.000000000 +0100
@@ -0,0 +1,17 @@
+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 <aurel32 at debian.org>
+--- ddnet-15.1.3.orig/CMakeLists.txt
++++ ddnet-15.1.3/CMakeLists.txt
+@@ -366,6 +366,7 @@ find_package(Pnglite)
+ find_package(PythonInterp 3)
+ find_package(SDL2)
+ find_package(SQLite3)
++set (THREADS_PREFER_PTHREAD_FLAG TRUE)
+ find_package(Threads)
+ find_package(Wavpack)
+ if(WEBSOCKETS)
--- ddnet-15.1.3/debian/patches/series 2020-07-01 17:27:01.000000000 +0200
+++ ddnet-15.1.3/debian/patches/series 2020-12-28 17:58:17.000000000 +0100
@@ -1,3 +1,4 @@
# even that ddnet won't render this system font
# match-fonts-materialdesignicons-webfont-codepoints.patch
use-system-libjsonparser.patch
+link-pthread.patch
More information about the Pkg-games-devel
mailing list