git: abd848c1c418 - main - devel/cpu_features: port to aarch64 and armv7
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 28 Sep 2025 09:30:54 UTC
The branch main has been updated by fuz:
URL: https://cgit.FreeBSD.org/ports/commit/?id=abd848c1c4182e3a1c8e7018565550e401a2cd6b
commit abd848c1c4182e3a1c8e7018565550e401a2cd6b
Author: Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2025-09-21 09:47:34 +0000
Commit: Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2025-09-28 09:29:32 +0000
devel/cpu_features: port to aarch64 and armv7
These platforms works largely the same way as Linux, so adapt the existing
Linux code path.
Approved by: portmgr (build fix blanket)
MFH: 2025Q3
---
devel/cpu_features/Makefile | 4 +-
devel/cpu_features/files/patch-src_hwcaps.c | 44 ++++++++++++++++++++++
.../patch-src_impl__aarch64__linux__or__android.c | 23 +++++++++++
.../patch-src_impl__arm__linux__or__android.c | 21 +++++++++++
4 files changed, 90 insertions(+), 2 deletions(-)
diff --git a/devel/cpu_features/Makefile b/devel/cpu_features/Makefile
index ec3a05d23b42..876fb8f8d28b 100644
--- a/devel/cpu_features/Makefile
+++ b/devel/cpu_features/Makefile
@@ -10,8 +10,8 @@ WWW= https://github.com/google/cpu_features
LICENSE= APACHE20
LICENSE_FILE= ${WRKSRC}/LICENSE
-NOT_FOR_ARCHS= aarch64 armv6 armv7 mips mips64 riscv64
-NOT_FOR_ARCHS_REASON= assumes android if on ARM or MIPS; not ported to riscv64
+NOT_FOR_ARCHS= mips mips64 riscv64
+NOT_FOR_ARCHS_REASON= assumes android if on MIPS; not ported to riscv64
USES= cmake:testing
USE_GITHUB= yes
diff --git a/devel/cpu_features/files/patch-src_hwcaps.c b/devel/cpu_features/files/patch-src_hwcaps.c
new file mode 100644
index 000000000000..4213c3b732de
--- /dev/null
+++ b/devel/cpu_features/files/patch-src_hwcaps.c
@@ -0,0 +1,44 @@
+--- src/hwcaps.c.orig 2023-09-14 12:15:33 UTC
++++ src/hwcaps.c
+@@ -55,12 +55,16 @@ const char* CpuFeatures_GetBasePlatformPointer(void);
+ // Implementation of GetElfHwcapFromGetauxval
+ ////////////////////////////////////////////////////////////////////////////////
+
+-#define AT_HWCAP 16
+-#define AT_HWCAP2 26
+-#define AT_PLATFORM 15
+-#define AT_BASE_PLATFORM 24
++#if defined(CPU_FEATURES_OS_FREEBSD)
++#include <sys/auxv.h>
++static unsigned long GetElfHwcapFromGetauxval(uint32_t hwcap_type) {
++ unsigned long val = 0;
+
+-#if defined(HAVE_STRONG_GETAUXVAL)
++ elf_aux_info(hwcap_type, &val, sizeof val);
++
++ return val;
++}
++#elif defined(HAVE_STRONG_GETAUXVAL)
+ #include <sys/auxv.h>
+ static unsigned long GetElfHwcapFromGetauxval(uint32_t hwcap_type) {
+ return getauxval(hwcap_type);
+@@ -159,11 +163,19 @@ const char *CpuFeatures_GetPlatformPointer(void) {
+ }
+
+ const char *CpuFeatures_GetPlatformPointer(void) {
++#ifdef AT_PLATFORM
+ return (const char *)GetHardwareCapabilitiesFor(AT_PLATFORM);
++#else
++ return NULL;
++#endif
+ }
+
+ const char *CpuFeatures_GetBasePlatformPointer(void) {
++#ifdef AT_BASE_PLATFORM
+ return (const char *)GetHardwareCapabilitiesFor(AT_BASE_PLATFORM);
++#else
++ return NULL;
++#endif
+ }
+
+ #endif // CPU_FEATURES_TEST
diff --git a/devel/cpu_features/files/patch-src_impl__aarch64__linux__or__android.c b/devel/cpu_features/files/patch-src_impl__aarch64__linux__or__android.c
new file mode 100644
index 000000000000..f3efc4ed6e47
--- /dev/null
+++ b/devel/cpu_features/files/patch-src_impl__aarch64__linux__or__android.c
@@ -0,0 +1,23 @@
+--- src/impl_aarch64_linux_or_android.c.orig 2025-09-21 09:37:44 UTC
++++ src/impl_aarch64_linux_or_android.c
+@@ -15,7 +15,7 @@
+ #include "cpu_features_macros.h"
+
+ #ifdef CPU_FEATURES_ARCH_AARCH64
+-#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
++#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID) || defined(CPU_FEATURES_OS_FREEBSD)
+
+ #include "impl_aarch64__base_implementation.inl"
+
+@@ -43,7 +43,11 @@ static void FillProcCpuInfoData(Aarch64Info* const inf
+ }
+
+ static void FillProcCpuInfoData(Aarch64Info* const info) {
++#ifdef CPU_FEATURES_OS_FREEBSD
++ const int fd = CpuFeatures_OpenFile("/compat/linux/proc/cpuinfo");
++#else
+ const int fd = CpuFeatures_OpenFile("/proc/cpuinfo");
++#endif
+ if (fd >= 0) {
+ StackLineReader reader;
+ StackLineReader_Initialize(&reader, fd);
diff --git a/devel/cpu_features/files/patch-src_impl__arm__linux__or__android.c b/devel/cpu_features/files/patch-src_impl__arm__linux__or__android.c
new file mode 100644
index 000000000000..65c638f9307c
--- /dev/null
+++ b/devel/cpu_features/files/patch-src_impl__arm__linux__or__android.c
@@ -0,0 +1,21 @@
+--- src/impl_arm_linux_or_android.c.orig 2025-09-21 09:55:17 UTC
++++ src/impl_arm_linux_or_android.c
+@@ -15,7 +15,7 @@
+ #include "cpu_features_macros.h"
+
+ #ifdef CPU_FEATURES_ARCH_ARM
+-#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
++#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID) || defined(CPU_FEATURES_OS_FREEBSD)
+
+ #include "cpuinfo_arm.h"
+
+@@ -195,7 +195,9 @@ ArmInfo GetArmInfo(void) {
+ ArmInfo info = kEmptyArmInfo;
+ ProcCpuInfoData proc_cpu_info_data = kEmptyProcCpuInfoData;
+
++#ifndef CPU_FEATURES_OS_FREEBSD
+ FillProcCpuInfoData(&info, &proc_cpu_info_data);
++#endif
+ const HardwareCapabilities hwcaps = CpuFeatures_GetHardwareCapabilities();
+ for (size_t i = 0; i < ARM_LAST_; ++i) {
+ if (CpuFeatures_IsHwCapsSet(kHardwareCapabilities[i], hwcaps)) {