Package: debhelper
Version: 13.7.1
Severity: important
X-Debbugs-Cc: debian-ri...@lists.debian.org

Dear Maintainer,

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
functionality.

There is also currently a gcc bug related to this, with ongoing
discussion on what to do long-term.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81358

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.
set(THREADS_PREFER_PTHREAD_FLAG ON)

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:
        fairy-stockfish
        leela-zero
        muse
        neochat
        rust-jemalloc-sys
        wsclean
        zynaddsubfx

Affected with a patch pending:
        simgear https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1011260
        thinkfan https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1011953
        warzone2100 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1011367

Affected with a patch applied:
        ceph https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=953003
        webkit2gtk https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=895969
        yoshimi 
https://sources.debian.org/src/yoshimi/2.2.0-2/debian/patches/fix_ftbfs_on_risc64.patch/

Affected with a patch applied, but does not use cmake:
        libzstd https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=895259

Similar unfixed problem, but not currently using -lpthread (need to use 
-latomic):
        numactl
        opentracing-cpp
        tiledb-r

Also, see here for existing occurrences of this cmake directive in Debian 
packages:
https://codesearch.debian.net/search?q=THREADS_PREFER_PTHREAD_FLAG

Special thanks to Bo YU <tsu.y...@gmail.com> for help in preparing this bug 
report.
-Alan Beadle <ab.bea...@gmail.com>


-- System Information:
Debian Release: bookworm/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: riscv64

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

Reply via email to