Source: numpy
Version: 1:2.2.2+ds-2
Severity: normal
Tags: ftbfs patch
User: debian-loonga...@lists.debian.org
Usertags: loong64
X-Debbugs-CC: debian-loonga...@lists.debian.org

Dear maintainers,

Compiling the numpy failed for loong64 in the Debian Package Auto-Building environment.
The error log is as follows,
```
......
In file included from ../numpy/_core/src/highway/hwy/highway.h:623,
                 from ../numpy/_core/src/umath/loops_trigonometric.dispatch.cpp:6: ../numpy/_core/src/highway/hwy/ops/generic_ops-inl.h:34:23: error: expected constructor, destructor, or type conversion before ‘;’ token
   34 | HWY_BEFORE_NAMESPACE();
      |                       ^
../numpy/_core/src/highway/hwy/ops/generic_ops-inl.h:66:9: error: ‘VFromD’ does not name a type    66 | HWY_API VFromD<D> CombineShiftRightLanes(D d, VFromD<D> hi, VFromD<D> lo) {
      |         ^~~~~~
../numpy/_core/src/highway/hwy/ops/generic_ops-inl.h: In function ‘hwy::HWY_NAMESPACE::Vec<D> hwy::HWY_NAMESPACE::SignBit(D)’: ../numpy/_core/src/highway/hwy/ops/generic_ops-inl.h:77:9: error: ‘RebindToUnsigned’ does not name a type
   77 |   const RebindToUnsigned<decltype(d)> du;
      |         ^~~~~~~~~~~~~~~~
../numpy/_core/src/highway/hwy/ops/generic_ops-inl.h:78:25: error: ‘du’ was not declared in this scope; did you mean ‘d’?
   78 |   return BitCast(d, Set(du, SignMask<TFromD<D>>()));
      |                         ^~
      |                         d
```

The full build log can be found at https://buildd.debian.org/status/fetch.php?pkg=numpy&arch=loong64&ver=1%3A2.2.2%2Bds-2&stamp=1738491494&raw=0.

After analysis, two points have been confirmed.
- numpy 2.2.2 release version synchronized with highway is highway@68b0fde (The sync is on Dec 5, 2024). highway@68b0fde commit: https://github.com/google/highway/tree/68b0fdebffb14f3b8473fed1c33ce368efc431e7 - need to cherry-pick upstream(highway) patch to fix above build error in _core/src/highway. commit(Dec 17, 2024): fix build in case building for loongarch already (not yet supported)
https://github.com/google/highway/commit/5cde138f2eb5adc2c48b3965ade527276dade891

Please consider the patch I attached for _core/src/highway.
Based on the attached patch, I have built numpy (1:2.2.2+ds-2+loong64) successfully on local ENV.
```
dpkg-deb: building package 'python3-numpy-dbgsym' in '../python3-numpy-dbgsym_2.2.2+ds-2+loong64_loong64.deb'. dpkg-deb: building package 'python3-numpy-dev' in '../python3-numpy-dev_2.2.2+ds-2+loong64_loong64.deb'. dpkg-deb: building package 'python-numpy-doc' in '../python-numpy-doc_2.2.2+ds-2+loong64_all.deb'. dpkg-deb: building package 'python3-numpy' in '../python3-numpy_2.2.2+ds-2+loong64_loong64.deb'.
 dpkg-genbuildinfo -O../numpy_2.2.2+ds-2+loong64_loong64.buildinfo
 dpkg-genchanges -O../numpy_2.2.2+ds-2+loong64_loong64.changes
```

Your opinions are welcome.

Best regards,
Dandan Zhang

Description: src/highway: Cherry-pick upstream patch to fix build error in _core/src/highway 
 .
 numpy (1:2.2.2+ds-2+loong64) unstable; urgency=medium
 .
   * _core/src/highway: fix build in case building 
     for loongarch already (not yet supported) 
Author: Dandan Zhang <zhangdan...@loongson.cn> Sat, 08 Feb 2025 16:11:03 +0800

---
Applied-Upstream: master, commit: https://github.com/google/highway/commit/5cde138f2eb5adc2c48b3965ade527276dade891
Reviewed-By: Bo Jin
Last-Update: 2025-02-08

--- numpy-2.2.2+ds.orig/numpy/_core/src/highway/hwy/detect_targets.h
+++ numpy-2.2.2+ds/numpy/_core/src/highway/hwy/detect_targets.h
@@ -615,6 +615,13 @@
 //------------------------------------------------------------------------------
 // Choose targets for dynamic dispatch according to one of four policies
 
+// TODO: remove once HWY_LSX is actually supported
+#if HWY_ARCH_LOONGARCH
+#undef HWY_COMPILE_ONLY_STATIC
+#undef HWY_COMPILE_ONLY_EMU128
+#define HWY_COMPILE_ONLY_SCALAR
+#endif
+
 #if 1 < (defined(HWY_COMPILE_ONLY_SCALAR) + defined(HWY_COMPILE_ONLY_EMU128) + \
          defined(HWY_COMPILE_ONLY_STATIC))
 #error "Can only define one of HWY_COMPILE_ONLY_{SCALAR|EMU128|STATIC} - bug?"

Reply via email to