aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2024-05-09 08:50:22 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2024-05-09 07:04:04 +0000
commit004e870f92730074685d56710b31c52115d1e8da (patch)
tree45a60081089e99f0cceaf8c01720fba3660b4eaa
parent9c10fcdab9d8d839f2d86c9489ddc6d363ab95e8 (diff)
community/zlib-ng: fix rvv detection on riscv64
The sophgo 2042 (milk-v pioneer) has RVV 0.7.1 which is not fully compatible. Fix the RVV test. Patch is adapted from: https://github.com/google/highway/pull/2127 Note that it only works on 64 bit RISC-V. upstream: https://github.com/zlib-ng/zlib-ng/issues/1705
-rw-r--r--community/zlib-ng/APKBUILD7
-rw-r--r--community/zlib-ng/fix-rvv-detection-riscv64.patch25
2 files changed, 30 insertions, 2 deletions
diff --git a/community/zlib-ng/APKBUILD b/community/zlib-ng/APKBUILD
index a58afa146e2..113feac04ca 100644
--- a/community/zlib-ng/APKBUILD
+++ b/community/zlib-ng/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=zlib-ng
pkgver=2.1.6
-pkgrel=0
+pkgrel=1
pkgdesc="zlib replacement with optimizations for next generation systems"
url="https://github.com/zlib-ng/zlib-ng"
arch="all"
@@ -10,7 +10,9 @@ license="Zlib"
makedepends="cmake samurai"
checkdepends="gzip xxd zlib-dev"
subpackages="$pkgname-dev"
-source="https://github.com/zlib-ng/zlib-ng/archive/$pkgver/zlib-ng-$pkgver.tar.gz"
+source="https://github.com/zlib-ng/zlib-ng/archive/$pkgver/zlib-ng-$pkgver.tar.gz
+ fix-rvv-detection-riscv64.patch
+ "
# secfixes:
# 2.0.6-r0:
@@ -47,4 +49,5 @@ package() {
sha512sums="
59ef586c09b9a63788475abfd6dd59ed602316b38f543f801bea802ff8bec8b55a89bee90375b8bbffa3bdebc7d92a00903f4b7c94cdc1a53a36e2e1fd71d13a zlib-ng-2.1.6.tar.gz
+22433ea48e49688acc6ba318a629362e71a704fe148aa8d0cde00ab9c88603ad0923ea4b3d756fa5261fb56801535111ec277b8665f8ac51a2220a8351c09e73 fix-rvv-detection-riscv64.patch
"
diff --git a/community/zlib-ng/fix-rvv-detection-riscv64.patch b/community/zlib-ng/fix-rvv-detection-riscv64.patch
new file mode 100644
index 00000000000..c673aff6e5d
--- /dev/null
+++ b/community/zlib-ng/fix-rvv-detection-riscv64.patch
@@ -0,0 +1,25 @@
+diff --git a/arch/riscv/riscv_features.c b/arch/riscv/riscv_features.c
+index b066f42..259a63a 100644
+--- a/arch/riscv/riscv_features.c
++++ b/arch/riscv/riscv_features.c
+@@ -42,4 +42,20 @@ void Z_INTERNAL riscv_check_features(struct riscv_cpu_features *features) {
+ riscv_check_features_runtime(features);
+ else
+ riscv_check_features_compile_time(features);
++ if (features->has_rvv) {
++ size_t e8m1_vec_len;
++ int64_t vtype_reg_val;
++ // Check that a vuint8m1_t vector is at least 16 bytes and that tail
++ // agnostic and mask agnostic mode are supported
++ //
++ __asm__ volatile(
++ "vsetvli %0, zero, e8, m1, ta, ma\n\t"
++ "csrr %1, vtype"
++ : "=r"(e8m1_vec_len), "=r"(vtype_reg_val));
++
++ // The RVV target is supported if the VILL bit of VTYPE (the MSB bit of
++ // VTYPE) is not set and the length of a vuint8m1_t vector is at least 16
++ // bytes
++ features->has_rvv = (vtype_reg_val >= 0 && e8m1_vec_len >= 16);
++ }
+ }