git: d4f7fe65a72f - main - sysutils/onefetch: fix build on powerpc*

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Fri, 16 Jun 2023 18:38:51 UTC
The branch main has been updated by pkubaj:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d4f7fe65a72ffa302b1f0bbe5e343a5e99d14749

commit d4f7fe65a72ffa302b1f0bbe5e343a5e99d14749
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2023-06-16 18:23:21 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2023-06-16 18:38:49 +0000

    sysutils/onefetch: fix build on powerpc*
    
      /wrkdirs/usr/ports/sysutils/onefetch/work/onefetch-2.17.1/cargo-crates/libz-ng-sys-1.1.8/src/zlib-ng/functable.c:125:9: error: use of undeclared identifier 'power_cpu_has_arch_3_00'
          if (power_cpu_has_arch_3_00)
              ^
      /wrkdirs/usr/ports/sysutils/onefetch/work/onefetch-2.17.1/cargo-crates/libz-ng-sys-1.1.8/src/zlib-ng/functable.c:158:9: error: use of undeclared identifier 'power_cpu_has_arch_3_00'
          if (power_cpu_has_arch_3_00)
              ^
      /wrkdirs/usr/ports/sysutils/onefetch/work/onefetch-2.17.1/cargo-crates/libz-ng-sys-1.1.8/src/zlib-ng/functable.c:451:9: error: use of undeclared identifier 'power_cpu_has_arch_3_00'
          if (power_cpu_has_arch_3_00)
---
 ...1.1.8_src_zlib-ng_arch_power_chunkset__power8.c | 11 +++++++
 ...-1.1.8_src_zlib-ng_arch_power_power__features.c | 36 ++++++++++++++++++++
 ...1.1.8_src_zlib-ng_cmake_detect-intrinsics.cmake | 38 ++++++++++++++++++++++
 3 files changed, 85 insertions(+)

diff --git a/sysutils/onefetch/files/patch-cargo-crates_libz-ng-sys-1.1.8_src_zlib-ng_arch_power_chunkset__power8.c b/sysutils/onefetch/files/patch-cargo-crates_libz-ng-sys-1.1.8_src_zlib-ng_arch_power_chunkset__power8.c
new file mode 100644
index 000000000000..8f8a5c324897
--- /dev/null
+++ b/sysutils/onefetch/files/patch-cargo-crates_libz-ng-sys-1.1.8_src_zlib-ng_arch_power_chunkset__power8.c
@@ -0,0 +1,11 @@
+--- cargo-crates/libz-ng-sys-1.1.8/src/zlib-ng/arch/power/chunkset_power8.c.orig	2022-12-29 16:08:43 UTC
++++ cargo-crates/libz-ng-sys-1.1.8/src/zlib-ng/arch/power/chunkset_power8.c
+@@ -27,7 +27,7 @@ static inline void chunkmemset_4(uint8_t *from, chunk_
+ }
+ 
+ static inline void chunkmemset_8(uint8_t *from, chunk_t *chunk) {
+-    uint64_t tmp;
++    unsigned long long tmp;
+     zmemcpy_8(&tmp, from);
+     *chunk = (vector unsigned char)vec_splats(tmp);
+ }
diff --git a/sysutils/onefetch/files/patch-cargo-crates_libz-ng-sys-1.1.8_src_zlib-ng_arch_power_power__features.c b/sysutils/onefetch/files/patch-cargo-crates_libz-ng-sys-1.1.8_src_zlib-ng_arch_power_power__features.c
new file mode 100644
index 000000000000..dd01fb3e6516
--- /dev/null
+++ b/sysutils/onefetch/files/patch-cargo-crates_libz-ng-sys-1.1.8_src_zlib-ng_arch_power_power__features.c
@@ -0,0 +1,36 @@
+--- cargo-crates/libz-ng-sys-1.1.8/src/zlib-ng/arch/power/power_features.c.orig	1973-11-29 21:33:09 UTC
++++ cargo-crates/libz-ng-sys-1.1.8/src/zlib-ng/arch/power/power_features.c
+@@ -7,6 +7,9 @@
+ #ifdef HAVE_SYS_AUXV_H
+ #  include <sys/auxv.h>
+ #endif
++#ifdef __FreeBSD__
++#include <machine/cpu.h>
++#endif
+ #include "../../zbuild.h"
+ #include "power_features.h"
+ 
+@@ -17,7 +20,11 @@ Z_INTERNAL int power_cpu_has_arch_3_00 = 0;
+ void Z_INTERNAL power_check_features(void) {
+ #ifdef PPC_FEATURES
+     unsigned long hwcap;
++#ifdef __FreeBSD__
++    elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
++#else
+     hwcap = getauxval(AT_HWCAP);
++#endif
+ 
+     if (hwcap & PPC_FEATURE_HAS_ALTIVEC)
+         power_cpu_has_altivec = 1;
+@@ -25,7 +32,11 @@ void Z_INTERNAL power_check_features(void) {
+ 
+ #ifdef POWER_FEATURES
+     unsigned long hwcap2;
++#ifdef __FreeBSD__
++    elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2));
++#else
+     hwcap2 = getauxval(AT_HWCAP2);
++#endif
+ 
+     if (hwcap2 & PPC_FEATURE2_ARCH_2_07)
+         power_cpu_has_arch_2_07 = 1;
diff --git a/sysutils/onefetch/files/patch-cargo-crates_libz-ng-sys-1.1.8_src_zlib-ng_cmake_detect-intrinsics.cmake b/sysutils/onefetch/files/patch-cargo-crates_libz-ng-sys-1.1.8_src_zlib-ng_cmake_detect-intrinsics.cmake
new file mode 100644
index 000000000000..8e82c8987617
--- /dev/null
+++ b/sysutils/onefetch/files/patch-cargo-crates_libz-ng-sys-1.1.8_src_zlib-ng_cmake_detect-intrinsics.cmake
@@ -0,0 +1,38 @@
+--- cargo-crates/libz-ng-sys-1.1.8/src/zlib-ng/cmake/detect-intrinsics.cmake.orig	1973-11-29 21:33:09 UTC
++++ cargo-crates/libz-ng-sys-1.1.8/src/zlib-ng/cmake/detect-intrinsics.cmake
+@@ -280,8 +280,17 @@ macro(check_ppc_intrinsics)
+     set(CMAKE_REQUIRED_FLAGS "${PPCFLAGS} ${NATIVEFLAG}")
+     check_c_source_compiles(
+         "#include <sys/auxv.h>
++        #ifdef __FreeBSD__
++        #include <machine/cpu.h>
++        #endif
+         int main() {
++        #ifdef __FreeBSD__
++            unsigned long hwcap;
++            elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
++            return (hwcap & PPC_FEATURE_HAS_ALTIVEC);
++        #else
+             return (getauxval(AT_HWCAP) & PPC_FEATURE_HAS_ALTIVEC);
++        #endif
+         }"
+         HAVE_VMX
+     )
+@@ -298,8 +307,17 @@ macro(check_power8_intrinsics)
+     set(CMAKE_REQUIRED_FLAGS "${POWER8FLAG} ${NATIVEFLAG}")
+     check_c_source_compiles(
+         "#include <sys/auxv.h>
++        #ifdef __FreeBSD__
++        #include <machine/cpu.h>
++        #endif
+         int main() {
++        #ifdef __FreeBSD__
++            unsigned long hwcap;
++            elf_aux_info(AT_HWCAP2, &hwcap, sizeof(hwcap));
++            return (hwcap & PPC_FEATURE2_ARCH_2_07);
++        #else
+             return (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_2_07);
++        #endif
+         }"
+         HAVE_POWER8_INTRIN
+     )