Bug#1012058: debhelper: riscv64 needs THREADS_PREFER_PTHREAD_FLAG in cmake for atomics-related ftbfs
On riscv64, many FTBFS issues share a root cause, and I believe it would
be appropriate to address it in debhelper. This architecture lacks hardware
support for small atomics. These operations must be implemented in software
instead of as instructions. The pthreads library includes this support, but
needs to be linked with "-pthread", and not "-lpthread" to use this
There is also currently a gcc bug related to this, with ongoing
discussion on what to do long-term.
The following cmake directive causes the build process to prefer -pthread
over -lpthread, and in this case, makes it possible to use small atomic
operations on riscv64.
Rather than applying a patch for this flag to every affected package
individually, it seems more sensible to apply it through debhelper. If
the architecture is riscv64, then the above cmake directive should be set.
I think this could be added in lib/Debian/Debhelper/Buildsystem/cmake.pm
Below I have gathered several relevant lists of packages.
These lists are probably incomplete.
Likely affected with no patch pending:
Affected with a patch pending:
Affected with a patch applied:
Affected with a patch applied, but does not use cmake:
Similar unfixed problem, but not currently using -lpthread (need to use -latomic):
Also, see here for existing occurrences of this cmake directive in Debian packages:
Special thanks to Bo YU <email@example.com> for help in preparing this bug report.
-Alan Beadle <firstname.lastname@example.org>
-- System Information:
Debian Release: bookworm/sid
APT prefers unstable
APT policy: (500, 'unstable')
Kernel: Linux 5.18.0-starfive-5.18 (SMP w/2 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages debhelper depends on:
ii autotools-dev 20220109.1
ii dh-autoreconf 20
ii dh-strip-nondeterminism 1.13.0-1
ii dpkg 1.21.8
ii dpkg-dev 1.21.8
ii dwz 0.14-1
ii file 1:5.41-4
ii libdebhelper-perl 13.7.1
ii libdpkg-perl 1.21.8
ii man-db 2.10.2-1
ii perl 5.34.0-4
ii po-debconf 1.0.21+nmu1
debhelper recommends no packages.
Versions of packages debhelper suggests:
pn dh-make <none>
-- no debconf information