]>
Commit | Line | Data |
---|---|---|
2d9f7af4 JP |
1 | From b1e48789d61d995740762f66f505385db42410a5 Mon Sep 17 00:00:00 2001 |
2 | From: Jan Palus <jpalus@fastmail.com> | |
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 <jpalus@fastmail.com> | |
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]) |