]> git.pld-linux.org Git - packages/tesseract.git/blame - neon-detect.patch
fix build on arm32 without neon
[packages/tesseract.git] / neon-detect.patch
CommitLineData
2d9f7af4
JP
1From b1e48789d61d995740762f66f505385db42410a5 Mon Sep 17 00:00:00 2001
2From: Jan Palus <jpalus@fastmail.com>
3Date: Mon, 30 Oct 2023 01:36:57 +0100
4Subject: [PATCH] Check if NEON extension are actually available
5
6User may pass own compiler flags to configure which override those
7provided by project through automake. Therefore it is possible for user
8on ARM platform to pass CXXFLAGS=-mfpu=vfp which will effectively
9disable NEON even though used compiler supports -mfpu=neon (since user
10supplied 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
14flags combined.
15
16Signed-off-by: Jan Palus <jpalus@fastmail.com>
17---
18 configure.ac | 18 ++++++++++++++----
19 1 file changed, 14 insertions(+), 4 deletions(-)
20
21diff --git a/configure.ac b/configure.ac
22index 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])
This page took 0.059135 seconds and 4 git commands to generate.