Index: ext/libyuv/source/cpu_id.cc
--- ext/libyuv/source/cpu_id.cc.orig
+++ ext/libyuv/source/cpu_id.cc
@@ -23,7 +23,8 @@
 #include <stdio.h>  // For fopen()
 #include <string.h>
 
-#if defined(__linux__) && defined(__aarch64__)
+#if (defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && \
+    defined(__aarch64__)
 #include <sys/auxv.h>  // For getauxval()
 #endif
 
@@ -179,7 +180,7 @@ LIBYUV_API SAFEBUFFERS int ArmCpuCaps(const char* cpui
 }
 
 #ifdef __aarch64__
-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
 // Define hwcap values ourselves: building with an old auxv header where these
 // hwcap values are not defined should not prevent features from being enabled.
 #define YUV_AARCH64_HWCAP_ASIMDDP (1UL << 20)
@@ -472,13 +473,20 @@ static SAFEBUFFERS int GetCpuFlags(void) {
   cpu_info |= kCpuHasLOONGARCH;
 #endif
 #if defined(__aarch64__)
-#if defined(__linux__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
+  unsigned long hwcap = 0;
+  unsigned long hwcap2 = 0;
+  elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
+  elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2));
+#else
   // getauxval is supported since Android SDK version 18, minimum at time of
   // writing is 21, so should be safe to always use this. If getauxval is
   // somehow disabled then getauxval returns 0, which will leave Neon enabled
   // since Neon is mandatory on AArch64.
   unsigned long hwcap = getauxval(AT_HWCAP);
   unsigned long hwcap2 = getauxval(AT_HWCAP2);
+#endif
   cpu_info = AArch64CpuCaps(hwcap, hwcap2);
 #else
   cpu_info = AArch64CpuCaps();
