[packages/tesseract] fix build on arm32 without neon
atler
atler at pld-linux.org
Thu Feb 29 21:22:43 CET 2024
commit 2d9f7af412cd0be73ce50fe17d68c368d582916f
Author: Jan Palus <atler at pld-linux.org>
Date: Thu Feb 29 21:07:42 2024 +0100
fix build on arm32 without neon
from: https://github.com/tesseract-ocr/tesseract/pull/4154
neon-detect.patch | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
tesseract.spec | 2 ++
2 files changed, 51 insertions(+)
---
diff --git a/tesseract.spec b/tesseract.spec
index bab92e3..3b5381b 100644
--- a/tesseract.spec
+++ b/tesseract.spec
@@ -16,6 +16,7 @@ Group: Applications/Graphics
#Source0Download: https://github.com/tesseract-ocr/tesseract/releases
Source0: https://github.com/tesseract-ocr/tesseract/archive/%{version}/%{name}-%{version}.tar.gz
# Source0-md5: 53de961804ccbcb83b73122f721d8f83
+Patch0: neon-detect.patch
URL: https://github.com/tesseract-ocr/
%{?with_opencl:BuildRequires: OpenCL-devel}
BuildRequires: asciidoc
@@ -92,6 +93,7 @@ Statyczne biblioteki Tesseracta.
%prep
%setup -q
+%patch0 -p1
%build
%{__libtoolize}
diff --git a/neon-detect.patch b/neon-detect.patch
new file mode 100644
index 0000000..0eeec7c
--- /dev/null
+++ b/neon-detect.patch
@@ -0,0 +1,49 @@
+From b1e48789d61d995740762f66f505385db42410a5 Mon Sep 17 00:00:00 2001
+From: Jan Palus <jpalus at fastmail.com>
+Date: Mon, 30 Oct 2023 01:36:57 +0100
+Subject: [PATCH] Check if NEON extension are actually available
+
+User may pass own compiler flags to configure which override those
+provided by project through automake. Therefore it is possible for user
+on ARM platform to pass CXXFLAGS=-mfpu=vfp which will effectively
+disable NEON even though used compiler supports -mfpu=neon (since user
+supplied flags take precedence compiler invocation will use flags:
+-mfpu=neon -mfpu=vfp). Instead of checking whether compiler supports
+-mfpu=neon flag, check if NEON extensions are available by checking if
+__ARM_NEON is defined when compiling with -mfpu=neon and user supplied
+flags combined.
+
+Signed-off-by: Jan Palus <jpalus at fastmail.com>
+---
+ configure.ac | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 0b38537229..0514b619c5 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -178,10 +178,20 @@ case "${host_cpu}" in
+ ;;
+
+ arm*)
+-
+- AX_CHECK_COMPILE_FLAG([-mfpu=neon], [neon=true], [neon=false], [$WERROR])
+- AM_CONDITIONAL([HAVE_NEON], $neon)
+- if $neon; then
++ SAVE_CXXFLAGS="$CXXFLAGS"
++ CXXFLAGS="-mfpu=neon $CXXFLAGS"
++ AC_MSG_CHECKING([for NEON support])
++ AC_COMPILE_IFELSE(
++ [AC_LANG_PROGRAM([], [[
++ #ifndef __ARM_NEON
++ #error
++ #endif
++ ]])],
++ [neon=yes], [neon=no])
++ AC_MSG_RESULT([$neon])
++ CXXFLAGS="$SAVE_CXXFLAGS"
++ AM_CONDITIONAL([HAVE_NEON], test "xyes" = "x$neon")
++ if test "xyes" = "$neon"; then
+ AC_DEFINE([HAVE_NEON], [1], [Enable NEON instructions])
+ NEON_CXXFLAGS="-mfpu=neon"
+ AC_SUBST([NEON_CXXFLAGS])
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/tesseract.git/commitdiff/2d9f7af412cd0be73ce50fe17d68c368d582916f
More information about the pld-cvs-commit
mailing list