Skip to content

Commit 2d9f7af

Browse files
committed
fix build on arm32 without neon
from: tesseract-ocr/tesseract#4154
1 parent 2e9a77d commit 2d9f7af

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

neon-detect.patch

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
From b1e48789d61d995740762f66f505385db42410a5 Mon Sep 17 00:00:00 2001
2+
From: Jan Palus <[email protected]>
3+
Date: Mon, 30 Oct 2023 01:36:57 +0100
4+
Subject: [PATCH] Check if NEON extension are actually available
5+
6+
User may pass own compiler flags to configure which override those
7+
provided by project through automake. Therefore it is possible for user
8+
on ARM platform to pass CXXFLAGS=-mfpu=vfp which will effectively
9+
disable NEON even though used compiler supports -mfpu=neon (since user
10+
supplied flags take precedence compiler invocation will use flags:
11+
-mfpu=neon -mfpu=vfp). Instead of checking whether compiler supports
12+
-mfpu=neon flag, check if NEON extensions are available by checking if
13+
__ARM_NEON is defined when compiling with -mfpu=neon and user supplied
14+
flags combined.
15+
16+
Signed-off-by: Jan Palus <[email protected]>
17+
---
18+
configure.ac | 18 ++++++++++++++----
19+
1 file changed, 14 insertions(+), 4 deletions(-)
20+
21+
diff --git a/configure.ac b/configure.ac
22+
index 0b38537229..0514b619c5 100644
23+
--- a/configure.ac
24+
+++ b/configure.ac
25+
@@ -178,10 +178,20 @@ case "${host_cpu}" in
26+
;;
27+
28+
arm*)
29+
-
30+
- AX_CHECK_COMPILE_FLAG([-mfpu=neon], [neon=true], [neon=false], [$WERROR])
31+
- AM_CONDITIONAL([HAVE_NEON], $neon)
32+
- if $neon; then
33+
+ SAVE_CXXFLAGS="$CXXFLAGS"
34+
+ CXXFLAGS="-mfpu=neon $CXXFLAGS"
35+
+ AC_MSG_CHECKING([for NEON support])
36+
+ AC_COMPILE_IFELSE(
37+
+ [AC_LANG_PROGRAM([], [[
38+
+ #ifndef __ARM_NEON
39+
+ #error
40+
+ #endif
41+
+ ]])],
42+
+ [neon=yes], [neon=no])
43+
+ AC_MSG_RESULT([$neon])
44+
+ CXXFLAGS="$SAVE_CXXFLAGS"
45+
+ AM_CONDITIONAL([HAVE_NEON], test "xyes" = "x$neon")
46+
+ if test "xyes" = "$neon"; then
47+
AC_DEFINE([HAVE_NEON], [1], [Enable NEON instructions])
48+
NEON_CXXFLAGS="-mfpu=neon"
49+
AC_SUBST([NEON_CXXFLAGS])

tesseract.spec

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Group: Applications/Graphics
1616
#Source0Download: https://github.com/tesseract-ocr/tesseract/releases
1717
Source0: https://github.com/tesseract-ocr/tesseract/archive/%{version}/%{name}-%{version}.tar.gz
1818
# Source0-md5: 53de961804ccbcb83b73122f721d8f83
19+
Patch0: neon-detect.patch
1920
URL: https://github.com/tesseract-ocr/
2021
%{?with_opencl:BuildRequires: OpenCL-devel}
2122
BuildRequires: asciidoc
@@ -92,6 +93,7 @@ Statyczne biblioteki Tesseracta.
9293

9394
%prep
9495
%setup -q
96+
%patch0 -p1
9597

9698
%build
9799
%{__libtoolize}

0 commit comments

Comments
 (0)