git: 31efc7fa161a - main - graphics/tesseract: Fix build on armv6/armv7

From: Mikael Urankar <mikael_at_FreeBSD.org>
Date: Sun, 03 Apr 2022 07:37:57 UTC
The branch main has been updated by mikael:

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

commit 31efc7fa161a0da4982f5a3bf687e6bee405395f
Author:     Robert Clausecker <fuz@fuz.su>
AuthorDate: 2022-04-02 13:54:54 +0000
Commit:     Mikael Urankar <mikael@FreeBSD.org>
CommitDate: 2022-04-03 07:37:54 +0000

    graphics/tesseract: Fix build on armv6/armv7
    
    Tesseract requires the <asm/hwcap.h> header to detect the availability
    of NEON instructions on armv7.  This commit adds a patch to use the
    appropriate FreeBSD interface for this purpose.  This issue has already
    been reported to up stream.
    
    See also:       https://github.com/tesseract-ocr/tesseract/pull/3782
    See also:       PR #263003
    
    PR:             263004
    Approved by:    portmgr (build fix blanket)
---
 .../tesseract/files/patch-src_arch_simddetect.cpp  | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/graphics/tesseract/files/patch-src_arch_simddetect.cpp b/graphics/tesseract/files/patch-src_arch_simddetect.cpp
new file mode 100644
index 000000000000..2e645a041b2e
--- /dev/null
+++ b/graphics/tesseract/files/patch-src_arch_simddetect.cpp
@@ -0,0 +1,41 @@
+--- src/arch/simddetect.cpp.orig	2022-04-02 13:06:33 UTC
++++ src/arch/simddetect.cpp
+@@ -55,10 +55,12 @@
+ #if defined(HAVE_NEON) && !defined(__aarch64__)
+ #  ifdef ANDROID
+ #    include <cpu-features.h>
+-#  else
+-/* Assume linux */
++#  elif defined(__linux__)
+ #    include <asm/hwcap.h>
+ #    include <sys/auxv.h>
++#  elif defined(__FreeBSD__)
++#    include <sys/auxv.h>
++#    include <sys/elf.h>
+ #  endif
+ #endif
+ 
+@@ -85,7 +87,7 @@ SIMDDetect SIMDDetect::detector;
+ bool SIMDDetect::neon_available_ = true;
+ #elif defined(HAVE_NEON)
+ // If true, then Neon has been detected.
+-bool SIMDDetect::neon_available_;
++bool SIMDDetect::neon_available_ = false;
+ #else
+ // If true, then AVX has been detected.
+ bool SIMDDetect::avx_available_;
+@@ -216,9 +218,12 @@ SIMDDetect::SIMDDetect() {
+     if (family == ANDROID_CPU_FAMILY_ARM)
+       neon_available_ = (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON);
+   }
+-#  else
+-  /* Assume linux */
++#  elif defined(__linux__)
+   neon_available_ = getauxval(AT_HWCAP) & HWCAP_NEON;
++#  elif defined(__FreeBSD__)
++  unsigned long hwcap = 0;
++  elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap);
++  neon_available_ = hwcap & HWCAP_NEON;
+ #  endif
+ #endif
+