Skip to content

Commit

Permalink
games/punchy: unbreak build on armv7
Browse files Browse the repository at this point in the history
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
  • Loading branch information
clausecker authored and jbeich committed Apr 28, 2023
1 parent d8e7e2c commit 5acf5a0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion games/punchy/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PORTNAME= punchy
DISTVERSIONPREFIX= v
DISTVERSION= 0.3.0
PORTREVISION= 4
PORTREVISION= 5
CATEGORIES= games wayland

MAINTAINER= jbeich@FreeBSD.org
Expand Down
50 changes: 32 additions & 18 deletions games/punchy/files/patch-v8
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 5acf5a0

Please sign in to comment.