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

Dear Maintainer,

If I understand correctly, the upstream has supported riscv64 
although it is still in the experimental stage from its readme[0]

I have a look at the ftbfs on riscv64:
https://buildd.debian.org/status/logs.php?pkg=onednn&arch=riscv64

The mainly issue is that we need to enable `DONEDNN_CPU_RUNTIME=SEQ` on
riscv64[1] then it uses uses a custom string to represent riscv64 also.
In addition to one commit backported from upstream, the package can be
built on my local build. But it’s really time-consuming(>10h).

The only issue for me is that should be enabled `lto` on riscv64 also,
but I got the error maybe due to I did not find right build dependences.
I will look this continuous.

```
 FAILED: cmTC_ae435
    : && /usr/bin/clang-17 -g -O2 -Werror=implicit-function-declaration 
-ffile-prefix-map=/<<PKGBUILDDIR>>=. -flt
o=auto -ffat-lto-objects -fstack-protector-strong -Wformat 
-Werror=format-security -fdiagnostics-color=always  -W
date-time -D_FORTIFY_SOURCE=2 -flto=auto -ffat-lto-objects -Wl,-z,relro 
-Wl,-z,now -Wl,--as-needed CMakeFiles/cmT
C_ae435.dir/testCCompiler.c.o -o cmTC_ae435   && :
    /usr/bin/ld: /usr/lib/llvm-17/bin/../lib/LLVMgold.so: error loading plugin: 
/usr/lib/llvm-17/bin/../lib/LLVMg
old.so: cannot open shared object file: No such file or directory
    clang-17: error: linker command failed with exit code 1 (use -v to see 
invocation)
    ninja: build stopped: subcommand failed.

```

Please review the patch and let me know any issues.

BR,
Bo

[0]: https://github.com/oneapi-src/oneDNN?tab=readme-ov-file#installation
[1]: https://github.com/oneapi-src/oneDNN/issues/1848#issuecomment-2026267079
diff -Nru onednn-3.5.3/debian/changelog onednn-3.5.3/debian/changelog
--- onednn-3.5.3/debian/changelog       2024-08-28 16:14:37.000000000 +0000
+++ onednn-3.5.3/debian/changelog       2024-08-29 15:18:05.000000000 +0000
@@ -1,3 +1,11 @@
+onednn (3.5.3-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Enable DONEDNN_CPU_RUNTIME=SEQ on riscv64 build it with clang. 
+    (Closes: #-1)
+
+ -- Bo YU <tsu.y...@gmail.com>  Thu, 29 Aug 2024 15:18:05 +0000
+
 onednn (3.5.3-1) unstable; urgency=medium
 
   [ Shengqi Chen ]
diff -Nru onednn-3.5.3/debian/control onednn-3.5.3/debian/control
--- onednn-3.5.3/debian/control 2024-08-28 15:58:46.000000000 +0000
+++ onednn-3.5.3/debian/control 2024-08-29 15:18:05.000000000 +0000
@@ -7,7 +7,8 @@
                debhelper-compat (= 13),
                libtbb-dev,
                ninja-build,
-               libsimde-dev (>= 0.7.0)
+               libsimde-dev (>= 0.7.0),
+              clang-17 [riscv64],
 Standards-Version: 4.7.0.1
 Homepage: https://github.com/oneapi-src/oneDNN
 Rules-Requires-Root: no
diff -Nru onednn-3.5.3/debian/patches/add-primitive-header-on-rv64.patch 
onednn-3.5.3/debian/patches/add-primitive-header-on-rv64.patch
--- onednn-3.5.3/debian/patches/add-primitive-header-on-rv64.patch      
1970-01-01 00:00:00.000000000 +0000
+++ onednn-3.5.3/debian/patches/add-primitive-header-on-rv64.patch      
2024-08-29 15:18:05.000000000 +0000
@@ -0,0 +1,15 @@
+Description: Add missing include common/primitive.hpp
+Applied-Upstream: https://github.com/oneapi-src/oneDNN/pull/2053
+Last-Update: 2024-08-29
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/src/cpu/rv64/rvv_nchw_pooling.hpp
++++ b/src/cpu/rv64/rvv_nchw_pooling.hpp
+@@ -19,6 +19,7 @@
+ #define RV64_NCHW_POOLING_HPP
+ 
+ #include "cpu/cpu_pooling_pd.hpp"
++#include "common/primitive.hpp"
+ 
+ namespace dnnl {
+ namespace impl {
diff -Nru onednn-3.5.3/debian/patches/series onednn-3.5.3/debian/patches/series
--- onednn-3.5.3/debian/patches/series  2024-08-28 15:58:46.000000000 +0000
+++ onednn-3.5.3/debian/patches/series  2024-08-29 15:18:05.000000000 +0000
@@ -0,0 +1 @@
+add-primitive-header-on-rv64.patch
diff -Nru onednn-3.5.3/debian/rules onednn-3.5.3/debian/rules
--- onednn-3.5.3/debian/rules   2024-08-28 16:14:22.000000000 +0000
+++ onednn-3.5.3/debian/rules   2024-08-29 15:18:05.000000000 +0000
@@ -5,6 +5,13 @@
 export DEB_LDFLAGS_MAINT_APPEND  = -Wl,--as-needed
 #export CLICOLOR_FORCE=ON
 
+ifneq (,$(filter $(DEB_BUILD_ARCH), riscv64))
+export DEB_BUILD_MAINT_OPTIONS += optimize=-lto
+
+export CC=clang-17
+export CXX=clang++-17
+endif
+
 %:
        dh $@ -Scmake+ninja
 
@@ -12,7 +19,9 @@
 override_dh_auto_configure:
        dh_auto_configure -- \
                -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-               -DONEDNN_ARCH_OPT_FLAGS=""
+               -DONEDNN_ARCH_OPT_FLAGS="" \
+               $(if $(filter 
riscv64,$(DEB_BUILD_ARCH)),-DONEDNN_CPU_RUNTIME=SEQ -DDNNL_TARGET_ARCH=RV64,)
+               
 
 override_dh_auto_test:
 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))

Attachment: signature.asc
Description: PGP signature

Reply via email to