1From c18466834e4f845dfc9383c6944a72f31a78fafc Mon Sep 17 00:00:00 2001
2From: Andrey <loukhnov@lotes-tm.ru>
3Date: Thu, 14 Nov 2024 05:51:54 +0300
4Subject: [PATCH 1/3] Correct cpu features detection during cross-compiation
5 (#4151)
6
7---
8 aconfigure | 48 +++++++++++++++++++++++++++++++++++++++++++++---
9 aconfigure.ac | 35 ++++++++++++++++++++++++++++++++---
10 2 files changed, 77 insertions(+), 6 deletions(-)
11
12diff --git a/aconfigure b/aconfigure
13index 57716969d..eac120472 100755
14--- a/aconfigure
15+++ b/aconfigure
16@@ -8997,6 +8997,36 @@ $as_echo "Checking if libyuv is disabled...no" >&6; }
17 fi
18
19
20+SAVED_CFLAGS="$CFLAGS"
21+case $target_cpu in
22+ arm*)
23+ CFLAGS="-mfpu=neon $CFLAGS"
24+ ;;
25+ aarch64*)
26+ CFLAGS="-march=armv8-a+simd $CFLAGS"
27+ ;;
28+esac
29+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
30+/* end confdefs.h. */
31+
32+int
33+main (void)
34+{
35+
36+ ;
37+ return 0;
38+}
39+_ACEOF
40+if ac_fn_c_try_compile "$LINENO"
41+then :
42+ ax_cv_support_neon_ext=yes
43+else $as_nop
44+ ax_cv_support_neon_ext=no
45+
46+fi
47+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
48+CFLAGS="$SAVED_CFLAGS"
49+
50
51
52
53@@ -9064,9 +9094,21 @@ $as_echo "Checking if libwebrtc is disabled...no" >&6; }
54 ;;
55 *win32* | *w32* | *darwin* | *linux*)
56 case $target in
57- armv7l*gnueabihf)
58- ac_webrtc_instset=neon
59- ac_webrtc_cflags="-DWEBRTC_ARCH_ARMV7 -mfloat-abi=hard -mfpu=neon"
60+ arm*gnueabihf)
61+ if test "x$ax_cv_support_neon_ext" = "xyes"; then
62+ ac_webrtc_instset=neon
63+ ac_webrtc_cflags="-DWEBRTC_ARCH_ARMV7 -mfloat-abi=hard -mfpu=neon"
64+ else
65+ ac_webrtc_instset=generic
66+ fi
67+ ;;
68+ aarch64*)
69+ if test "x$ax_cv_support_neon_ext" = "xyes"; then
70+ ac_webrtc_instset=neon
71+ ac_webrtc_cflags="-DWEBRTC_ARCH_ARM64"
72+ else
73+ ac_webrtc_instset=generic
74+ fi
75 ;;
76 arm-apple-darwin*)
77 ac_webrtc_instset=neon
78diff --git a/aconfigure.ac b/aconfigure.ac
79index 48ff9f18e..fc472c7de 100644
80--- a/aconfigure.ac
81+++ b/aconfigure.ac
82@@ -2057,6 +2057,23 @@ AC_ARG_ENABLE(libyuv,
83 AC_MSG_RESULT([Checking if libyuv is disabled...no]))
84
85
86+dnl proper neon detector
87+SAVED_CFLAGS="$CFLAGS"
88+case $target_cpu in
89+ arm*)
90+ CFLAGS="-mfpu=neon $CFLAGS"
91+ ;;
92+ aarch64*)
93+ CFLAGS="-march=armv8-a+simd $CFLAGS"
94+ ;;
95+esac
96+AC_COMPILE_IFELSE(
97+ [AC_LANG_PROGRAM()],
98+ [ax_cv_support_neon_ext=yes],
99+ [ax_cv_support_neon_ext=no]
100+)
101+CFLAGS="$SAVED_CFLAGS"
102+
103 dnl # Include webrtc
104 AC_SUBST(ac_no_webrtc)
105 AC_SUBST(ac_webrtc_instset)
106@@ -2121,9 +2138,21 @@ AC_ARG_ENABLE(libwebrtc,
107 ;;
108 *win32* | *w32* | *darwin* | *linux*)
109 case $target in
110- armv7l*gnueabihf)
111- ac_webrtc_instset=neon
112- ac_webrtc_cflags="-DWEBRTC_ARCH_ARMV7 -mfloat-abi=hard -mfpu=neon"
113+ arm*gnueabihf)
114+ if test "x$ax_cv_support_neon_ext" = "xyes"; then
115+ ac_webrtc_instset=neon
116+ ac_webrtc_cflags="-DWEBRTC_ARCH_ARMV7 -mfloat-abi=hard -mfpu=neon"
117+ else
118+ ac_webrtc_instset=generic
119+ fi
120+ ;;
121+ aarch64*)
122+ if test "x$ax_cv_support_neon_ext" = "xyes"; then
123+ ac_webrtc_instset=neon
124+ ac_webrtc_cflags="-DWEBRTC_ARCH_ARM64"
125+ else
126+ ac_webrtc_instset=generic
127+ fi
128 ;;
129 *)
130 ac_webrtc_instset=sse2
131--
1322.50.1
133