Bug#978562: opendht: FTBFS on riscv64, linked with -lpthread instead of -pthread

2021-01-04 Thread Aurelien Jarno
On 2021-01-01 14:05, Alexandre Viau wrote:
> On Wed, 30 Dec 2020 at 10:46, Amin Bandali
>  wrote:
> > Alexandre, let's bump Debian's opendht and upload it to unstable.
> 
> Done!
> 
> Thank you both for your work :)

Thanks, for the quick fix, I confirm opendht now builds fine on riscv64.

Aurelien

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Bug#978562: opendht: FTBFS on riscv64, linked with -lpthread instead of -pthread

2021-01-01 Thread Alexandre Viau
On Wed, 30 Dec 2020 at 10:46, Amin Bandali
 wrote:
> Alexandre, let's bump Debian's opendht and upload it to unstable.

Done!

Thank you both for your work :)



Bug#978562: opendht: FTBFS on riscv64, linked with -lpthread instead of -pthread

2020-12-30 Thread Amin Bandali
Hello,

Aurelien Jarno writes:

> Hi,
>
> On 2020-12-28 18:01, Amin Bandali wrote:
>> Hello Alexandre, Aurelien,
>> 
>> Thanks for the patch.  I don't have access to any riscv64 machines to
>> test this.  However if you confirm that it fixes the build on riscv64
>> and introduces no regressions on any arches then I'll ask for it to be
>> applied upstream.
>
> I have tested it on riscv64, and I confirm it builds fine. As for
> regression on other architectures, I have also tested this patch on
> amd64 and i386. By experience, I doubt it will create any regression.

I see, thank you!  opendht 2.1.10 [0] has just been released including
the proposed change. :-)

[0]: https://github.com/savoirfairelinux/opendht/releases/tag/2.1.10

Alexandre, let's bump Debian's opendht and upload it to unstable.

> Aurelien

Thanks,

-- 
Amin Bandali
Free Software Consultant
Savoir-faire Linux
jami:bandali



Bug#978562: opendht: FTBFS on riscv64, linked with -lpthread instead of -pthread

2020-12-29 Thread Aurelien Jarno
Hi,

On 2020-12-28 18:01, Amin Bandali wrote:
> Hello Alexandre, Aurelien,
> 
> Thanks for the patch.  I don't have access to any riscv64 machines to
> test this.  However if you confirm that it fixes the build on riscv64
> and introduces no regressions on any arches then I'll ask for it to be
> applied upstream.

I have tested it on riscv64, and I confirm it builds fine. As for
regression on other architectures, I have also tested this patch on
amd64 and i386. By experience, I doubt it will create any regression.

Aurelien

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Bug#978562: opendht: FTBFS on riscv64, linked with -lpthread instead of -pthread

2020-12-28 Thread Amin Bandali
Hello Alexandre, Aurelien,

Thanks for the patch.  I don't have access to any riscv64 machines to
test this.  However if you confirm that it fixes the build on riscv64
and introduces no regressions on any arches then I'll ask for it to be
applied upstream.

Thanks,

-- 
Amin Bandali
Free Software Consultant
Savoir-faire Linux
jami:bandali



Bug#978562: opendht: FTBFS on riscv64, linked with -lpthread instead of -pthread

2020-12-28 Thread Alexandre Viau
Hello Amin,

Would you consider merging this directly into opendht?

Cheers,

--
Alexandre Viau
alexan...@alexandreviau.net

On Mon, 28 Dec 2020 at 11:45, Aurelien Jarno  wrote:
>
> Source: opendht
> Version: 2.1.9.5-1
> Severity: normal
> Tags: ftbfs patch upstream
> User: debian-ri...@lists.debian.org
> Usertags: riscv64
>
> Hi,
>
> opendht fails to build on riscv64 with the following failure:
> | /usr/bin/c++ -g -O2 -fdebug-prefix-map=/<>=. 
> -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
> -D_FORTIFY_SOURCE=2 -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor 
> -pedantic-errors -fvisibility=hidden -DMSGPACK_DISABLE_LEGACY_NIL 
> -DMSGPACK_DISABLE_LEGACY_CONVERT -Wl,-z,relro -Wl,-z,now -rdynamic 
> CMakeFiles/durl.dir/durl.cpp.o -o durl  -lreadline -lncurses ../libopendht.a 
> -largon2 -lrt -ldl -lpthread -lgnutls -lnettle -ljsoncpp -Wl,-Bstatic -lfmt 
> -Wl,-Bdynamic -lhttp_parser -lssl -lcrypto -ldl -lpthread -lgnutls -lnettle 
> -ljsoncpp -Wl,-Bstatic -lfmt -Wl,-Bdynamic -lhttp_parser -lssl -lcrypto
> | /usr/bin/ld: ../libopendht.a(http.cpp.o): in function `.L0 ':
> | /usr/include/asio/detail/completion_handler.hpp:72: undefined reference to 
> `__atomic_exchange_1'
> | /usr/bin/ld: ../libopendht.a(network_utils.cpp.o): in function 
> `dht::net::UdpSocket::stop()':
> | ./obj-riscv64-linux-gnu/./src/network_utils.cpp:350: undefined reference to 
> `__atomic_exchange_1'
> | /usr/bin/ld: ../libopendht.a(dht_proxy_client.cpp.o): in function 
> `__gnu_cxx::__exchange_and_add_single(int*, int)':
> | /usr/include/c++/10/ext/atomicity.h:69: 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=opendht=riscv64=2.1.9.5-1=1607520181=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



Bug#978562: opendht: FTBFS on riscv64, linked with -lpthread instead of -pthread

2020-12-28 Thread Aurelien Jarno
Source: opendht
Version: 2.1.9.5-1
Severity: normal
Tags: ftbfs patch upstream
User: debian-ri...@lists.debian.org
Usertags: riscv64

Hi,

opendht fails to build on riscv64 with the following failure:
| /usr/bin/c++ -g -O2 -fdebug-prefix-map=/<>=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time 
-D_FORTIFY_SOURCE=2 -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor 
-pedantic-errors -fvisibility=hidden -DMSGPACK_DISABLE_LEGACY_NIL 
-DMSGPACK_DISABLE_LEGACY_CONVERT -Wl,-z,relro -Wl,-z,now -rdynamic 
CMakeFiles/durl.dir/durl.cpp.o -o durl  -lreadline -lncurses ../libopendht.a 
-largon2 -lrt -ldl -lpthread -lgnutls -lnettle -ljsoncpp -Wl,-Bstatic -lfmt 
-Wl,-Bdynamic -lhttp_parser -lssl -lcrypto -ldl -lpthread -lgnutls -lnettle 
-ljsoncpp -Wl,-Bstatic -lfmt -Wl,-Bdynamic -lhttp_parser -lssl -lcrypto 
| /usr/bin/ld: ../libopendht.a(http.cpp.o): in function `.L0 ':
| /usr/include/asio/detail/completion_handler.hpp:72: undefined reference to 
`__atomic_exchange_1'
| /usr/bin/ld: ../libopendht.a(network_utils.cpp.o): in function 
`dht::net::UdpSocket::stop()':
| ./obj-riscv64-linux-gnu/./src/network_utils.cpp:350: undefined reference to 
`__atomic_exchange_1'
| /usr/bin/ld: ../libopendht.a(dht_proxy_client.cpp.o): in function 
`__gnu_cxx::__exchange_and_add_single(int*, int)':
| /usr/include/c++/10/ext/atomicity.h:69: 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=opendht=riscv64=2.1.9.5-1=1607520181=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
--- opendht-2.1.9.5/debian/patches/link-pthread.patch   1970-01-01 
00:00:00.0 +
+++ opendht-2.1.9.5/debian/patches/link-pthread.patch   2020-12-28 
10:55:59.0 +
@@ -0,0 +1,18 @@
+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 
+
+--- opendht-2.1.9.5.orig/CMakeLists.txt
 opendht-2.1.9.5/CMakeLists.txt
+@@ -42,6 +42,7 @@ option (OPENDHT_DOCUMENTATION "Create an
+ # Dependencies
+ list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
+ if (NOT MSVC)
++set (THREADS_PREFER_PTHREAD_FLAG TRUE)
+ find_package (Threads)
+ find_package (PkgConfig REQUIRED)
+ find_package (GnuTLS 3.3 REQUIRED)
--- opendht-2.1.9.5/debian/patches/series   2020-12-08 22:56:05.0 
+
+++ opendht-2.1.9.5/debian/patches/series   2020-12-28 10:55:59.0 
+
@@ -1 +1,2 @@
 pkgconfig-static.patch
+link-pthread.patch