git: 5acf5a02777b - main - games/punchy: unbreak build on armv7

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Fri, 28 Apr 2023 20:45:22 UTC
The branch main has been updated by jbeich:

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

commit 5acf5a02777bd9c6cce20980859c4316b267f6f2
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2023-04-26 00:36:30 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2023-04-28 20:44:40 +0000

    games/punchy: unbreak build on armv7
    
    Fix files/patch-v8 to compile on armv7 by refactoring it to use
    ELF auxilliary vectors in the CPU detection code and by adding
    some missing includes.
    
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:137:20: warning: implicit declaration of function 'READ_SPECIALREG' is invalid in C99 [-Wimplicit-function-declaration]
        id_aa64isar0 = READ_SPECIALREG(id_aa64isar0_el1);
                       ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:137:36: error: use of undeclared identifier 'id_aa64isar0_el1'; did you mean 'id_aa64isar0'?
        id_aa64isar0 = READ_SPECIALREG(id_aa64isar0_el1);
                                       ^~~~~~~~~~~~~~~~
                                       id_aa64isar0
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:136:14: note: 'id_aa64isar0' declared here
        uint64_t id_aa64isar0;
                 ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:138:9: warning: implicit declaration of function 'ID_AA64ISAR0_AES' is invalid in C99 [-Wimplicit-function-declaration]
        if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) == ID_AA64ISAR0_AES_PMULL)
            ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:42:30: note: expanded from macro 'ID_AA64ISAR0_AES_VAL'
     #define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES
                                  ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:138:47: error: use of undeclared identifier 'ID_AA64ISAR0_AES_PMULL'; did you mean 'ID_AA64ISAR0_AES'?
        if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) == ID_AA64ISAR0_AES_PMULL)
                                                  ^~~~~~~~~~~~~~~~~~~~~~
                                                  ID_AA64ISAR0_AES
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:138:9: note: 'ID_AA64ISAR0_AES' declared here
        if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) == ID_AA64ISAR0_AES_PMULL)
            ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:42:30: note: expanded from macro 'ID_AA64ISAR0_AES_VAL'
     #define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES
                                  ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:140:9: warning: implicit declaration of function 'ID_AA64ISAR0_CRC32' is invalid in C99 [-Wimplicit-function-declaration]
        if (ID_AA64ISAR0_CRC32_VAL(id_aa64isar0) == ID_AA64ISAR0_CRC32_BASE)
            ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:45:32: note: expanded from macro 'ID_AA64ISAR0_CRC32_VAL'
     #define ID_AA64ISAR0_CRC32_VAL ID_AA64ISAR0_CRC32
                                    ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:140:49: error: use of undeclared identifier 'ID_AA64ISAR0_CRC32_BASE'; did you mean 'ID_AA64ISAR0_CRC32'?
        if (ID_AA64ISAR0_CRC32_VAL(id_aa64isar0) == ID_AA64ISAR0_CRC32_BASE)
                                                    ^~~~~~~~~~~~~~~~~~~~~~~
                                                    ID_AA64ISAR0_CRC32
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:140:9: note: 'ID_AA64ISAR0_CRC32' declared here
        if (ID_AA64ISAR0_CRC32_VAL(id_aa64isar0) == ID_AA64ISAR0_CRC32_BASE)
            ^
    cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c:45:32: note: expanded from macro 'ID_AA64ISAR0_CRC32_VAL'
     #define ID_AA64ISAR0_CRC32_VAL ID_AA64ISAR0_CRC32
                                    ^
    
    PR:             271076
    Reported by:    pkg-fallout
---
 games/punchy/Makefile       |  2 +-
 games/punchy/files/patch-v8 | 50 +++++++++++++++++++++++++++++----------------
 2 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/games/punchy/Makefile b/games/punchy/Makefile
index d3193992c954..be709fe5c6e3 100644
--- a/games/punchy/Makefile
+++ b/games/punchy/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	punchy
 DISTVERSIONPREFIX=	v
 DISTVERSION=	0.3.0
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	games wayland
 
 MAINTAINER=	jbeich@FreeBSD.org
diff --git a/games/punchy/files/patch-v8 b/games/punchy/files/patch-v8
index 1b0bd8761916..c21a41bf51b8 100644
--- a/games/punchy/files/patch-v8
+++ b/games/punchy/files/patch-v8
@@ -424,7 +424,7 @@ error[E0308]: mismatched types
        } else if (is_mac) {
 --- cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c.orig	1970-01-01 00:00:00 UTC
 +++ cargo-crates/v8-0.47.1/third_party/zlib/cpu_features.c
-@@ -31,11 +31,20 @@ int ZLIB_INTERNAL x86_cpu_enable_simd = 0;
+@@ -31,11 +31,13 @@ int ZLIB_INTERNAL x86_cpu_enable_simd = 0;
  
  #ifndef CPU_NO_SIMD
  
@@ -435,19 +435,12 @@ error[E0308]: mismatched types
  
 -#if defined(ARMV8_OS_ANDROID)
 +#if defined(ARMV8_OS_FREEBSD)
-+#include <machine/armreg.h>
-+#include <sys/types.h>
-+#ifndef ID_AA64ISAR0_AES_VAL
-+#define ID_AA64ISAR0_AES_VAL ID_AA64ISAR0_AES
-+#endif
-+#ifndef ID_AA64ISAR0_CRC32_VAL
-+#define ID_AA64ISAR0_CRC32_VAL ID_AA64ISAR0_CRC32
-+#endif
++#include <sys/auxv.h>
 +#elif defined(ARMV8_OS_ANDROID)
  #include <cpu-features.h>
  #elif defined(ARMV8_OS_LINUX)
  #include <asm/hwcap.h>
-@@ -56,7 +65,7 @@ static void _cpu_check_features(void);
+@@ -56,7 +58,7 @@ static void _cpu_check_features(void);
  static void _cpu_check_features(void);
  #endif
  
@@ -456,17 +449,20 @@ error[E0308]: mismatched types
  #if !defined(ARMV8_OS_MACOS)
  // _cpu_check_features() doesn't need to do anything on mac/arm since all
  // features are known at build time, so don't call it.
-@@ -123,6 +132,13 @@ static void _cpu_check_features(void)
+@@ -123,6 +125,16 @@ static void _cpu_check_features(void)
  #elif defined(ARMV8_OS_WINDOWS)
      arm_cpu_enable_crc32 = IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);
      arm_cpu_enable_pmull = IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE);
-+#elif defined(ARMV8_OS_FREEBSD)
-+    uint64_t id_aa64isar0;
-+    id_aa64isar0 = READ_SPECIALREG(id_aa64isar0_el1);
-+    if (ID_AA64ISAR0_AES_VAL(id_aa64isar0) == ID_AA64ISAR0_AES_PMULL)
-+        arm_cpu_enable_pmull = 1;
-+    if (ID_AA64ISAR0_CRC32_VAL(id_aa64isar0) == ID_AA64ISAR0_CRC32_BASE)
-+        arm_cpu_enable_crc32 = 1;
++#elif defined(ARMV8_OS_FREEBSD) && defined(__aarch64__)
++    unsigned long features;
++    elf_aux_info(AT_HWCAP, &features, sizeof features);
++    arm_cpu_enable_crc32 = !!(features & HWCAP_CRC32);
++    arm_cpu_enable_pmull = !!(features & HWCAP_PMULL);
++#elif defined(ARMV8_OS_FREEBSD) /* aarch32 */
++    unsigned long features;
++    elf_aux_info(AT_HWCAP2, &features, sizeof features);
++    arm_cpu_enable_crc32 = !!(features & HWCAP2_CRC32);
++    arm_cpu_enable_pmull = !!(features & HWCAP2_PMULL);
  #endif
  }
  #endif
@@ -590,3 +586,21 @@ error[E0308]: mismatched types
  
  // static
  Stack::StackSlot Stack::GetStackStart() {
+--- cargo-crates/v8-0.47.1/v8/src/codegen/arm/cpu-arm.cc.orig	1970-01-01 00:00:00 UTC
++++ cargo-crates/v8-0.47.1/v8/src/codegen/arm/cpu-arm.cc
+@@ -2,12 +2,15 @@
+ // Use of this source code is governed by a BSD-style license that can be
+ // found in the LICENSE file.
+ 
++#include "include/v8config.h"
++
+ // CPU specific code for arm independent of OS goes here.
+ #ifdef __arm__
+ #ifdef __QNXNTO__
+ #include <sys/mman.h>  // for cache flushing.
+ #undef MAP_TYPE
+ #elif V8_OS_FREEBSD
++#include <sys/cdefs.h>
+ #include <machine/sysarch.h>  // for cache flushing
+ #include <sys/types.h>
+ #elif V8_OS_STARBOARD