Source: bfs
Version: 3.3.1-1
Severity: important
Tags: ftbfs, patch
User: debian-ri...@lists.debian.org
Usertags: riscv64
X-Debbugs-Cc: debian-ri...@lists.debian.org

Dear Maintainer,

bfs has one ftbfs issue on riscv64:

```
....
[ CC ] src/stat.c
/tmp/ccR1L1lA.s: Assembler messages:
/tmp/ccR1L1lA.s:670: Error: unrecognized opcode `pause', extension 
`zihintpause' required
make[1]: *** [Makefile:66: obj/src/sighook.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
...
```

The full buildd log is here:
https://buildd.debian.org/status/fetch.php?pkg=bfs&arch=riscv64&ver=3.3.1-1&stamp=1717488400&raw=0

It seems the gcc(13) does not support `zihintpause` extension by default
unless the extension is enabled in `-march`.

Fortunately upstream has submitted one commit[0] to fix the issue and I
have tested it on my local real riscv64 hardware. Could you apply it on
next upload to fix the issue?

[0]: 
https://github.com/tavianator/bfs/commit/e93a1dccd82f831a2f0d2cc382d8af5e1fda55ed

-- 
Regards,
--
  Bo YU

diff -Nru bfs-3.3.1/debian/changelog bfs-3.3.1/debian/changelog
--- bfs-3.3.1/debian/changelog  2024-06-04 15:26:30.000000000 +0800
+++ bfs-3.3.1/debian/changelog  2024-06-10 22:55:31.000000000 +0800
@@ -1,3 +1,10 @@
+bfs (3.3.1-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix ftbfs on riscv64. (Closes: #-1)
+
+ -- Bo YU <tsu.y...@gmail.com>  Mon, 10 Jun 2024 22:55:31 +0800
+
 bfs (3.3.1-1) unstable; urgency=medium
 
   * New upstream release.
diff -Nru bfs-3.3.1/debian/patches/00-fix-riscv64-ftbfs.patch 
bfs-3.3.1/debian/patches/00-fix-riscv64-ftbfs.patch
--- bfs-3.3.1/debian/patches/00-fix-riscv64-ftbfs.patch 1970-01-01 
08:00:00.000000000 +0800
+++ bfs-3.3.1/debian/patches/00-fix-riscv64-ftbfs.patch 2024-06-10 
22:55:20.000000000 +0800
@@ -0,0 +1,52 @@
+From e93a1dccd82f831a2f0d2cc382d8af5e1fda55ed Mon Sep 17 00:00:00 2001
+From: Tavian Barnes <taviana...@tavianator.com>
+Date: Thu, 6 Jun 2024 10:23:14 -0400
+Subject: [PATCH] atomic: Fix RISC-V build with GCC < 14
+
+Prior to GCC 14.1, the __builtin_riscv_pause() can cause an error if the
+appropriate extension is not enabled in -march:
+
+    /tmp/ccR1L1lA.s: Assembler messages:
+    /tmp/ccR1L1lA.s:670: Error: unrecognized opcode `pause', extension 
`zihintpause' required
+
+Link: https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626748.html
+Link: 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=c2d04dd659c499d8df19f68d0602ad4c7d7065c2
+Link: 
https://buildd.debian.org/status/fetch.php?pkg=bfs&arch=riscv64&ver=3.3.1-1&stamp=1717488400&raw=0
+---
+ build/has/builtin-riscv-pause.c | 7 +++++++
+ build/header.mk                 | 1 +
+ src/atomic.h                    | 2 +-
+ 3 files changed, 9 insertions(+), 1 deletion(-)
+ create mode 100644 build/has/builtin-riscv-pause.c
+
+--- /dev/null
++++ b/build/has/builtin-riscv-pause.c
+@@ -0,0 +1,7 @@
++// Copyright © Tavian Barnes <taviana...@tavianator.com>
++// SPDX-License-Identifier: 0BSD
++
++int main(void) {
++      __builtin_riscv_pause();
++      return 0;
++}
+--- a/build/header.mk
++++ b/build/header.mk
+@@ -16,6 +16,7 @@
+     gen/has/acl-is-trivial-np.h \
+     gen/has/acl-trivial.h \
+     gen/has/aligned-alloc.h \
++    gen/has/builtin-riscv-pause.h \
+     gen/has/confstr.h \
+     gen/has/extattr-get-file.h \
+     gen/has/extattr-get-link.h \
+--- a/src/atomic.h
++++ b/src/atomic.h
+@@ -109,7 +109,7 @@
+ #  define spin_loop() __builtin_ia32_pause()
+ #elif __has_builtin(__builtin_arm_yield)
+ #  define spin_loop() __builtin_arm_yield()
+-#elif __has_builtin(__builtin_riscv_pause)
++#elif BFS_HAS_BUILTIN_RISCV_PAUSE
+ #  define spin_loop() __builtin_riscv_pause()
+ #else
+ #  define spin_loop() ((void)0)
diff -Nru bfs-3.3.1/debian/patches/series bfs-3.3.1/debian/patches/series
--- bfs-3.3.1/debian/patches/series     1970-01-01 08:00:00.000000000 +0800
+++ bfs-3.3.1/debian/patches/series     2024-06-10 22:54:59.000000000 +0800
@@ -0,0 +1 @@
+00-fix-riscv64-ftbfs.patch

Attachment: signature.asc
Description: PGP signature

Reply via email to