summaryrefslogtreecommitdiffstats
path: root/meta/recipes-multimedia/pulseaudio/pulseaudio/0001-build-sys-meson-check-if-NEON-code-can-be-compiled-o.patch
blob: 5d9370fb165a37f9c6b29222a5eadb99b6ec597c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From 09f846fbdeb19193e778ce51baa77bd03c38372e Mon Sep 17 00:00:00 2001
From: garrison <garrison@qemu15.qemu-network>
Date: Fri, 4 Jun 2021 22:13:02 +0000
Subject: [PATCH] build-sys: meson: check if NEON code can be compiled on arm

When Meson SIMD module returns HAVE_NEON=1 on arm host, do extra compile check
to verify compiler can actually handle NEON code.

Related Meson issue #6361 https://github.com/mesonbuild/meson/issues/6361

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/574>

Upstream-Status: Backport[https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/6d2a49a6a1eacc2096d0d9473a074421c181ab56]

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
 src/pulsecore/meson.build | 41 +++++++++++++++++++++++++++++----------
 1 file changed, 31 insertions(+), 10 deletions(-)

diff --git a/src/pulsecore/meson.build b/src/pulsecore/meson.build
index 99a702e..d0b7990 100644
--- a/src/pulsecore/meson.build
+++ b/src/pulsecore/meson.build
@@ -172,16 +172,37 @@ endif
 
 # FIXME: SIMD support (ORC)
 simd = import('unstable-simd')
-libpulsecore_simd = simd.check('libpulsecore_simd',
-  mmx : ['remap_mmx.c', 'svolume_mmx.c'],
-  sse : ['remap_sse.c', 'sconv_sse.c', 'svolume_sse.c'],
-  neon : ['remap_neon.c', 'sconv_neon.c', 'mix_neon.c'],
-  c_args : [pa_c_args],
-  include_directories : [configinc, topinc],
-  implicit_include_directories : false,
-  compiler : cc)
-libpulsecore_simd_lib = libpulsecore_simd[0]
-cdata.merge_from(libpulsecore_simd[1])
+simd_variants = [
+  { 'mmx' : ['remap_mmx.c', 'svolume_mmx.c'] },
+  { 'sse' : ['remap_sse.c', 'sconv_sse.c', 'svolume_sse.c'] },
+  { 'neon' : ['remap_neon.c', 'sconv_neon.c', 'mix_neon.c'] },
+]
+
+libpulsecore_simd_lib = []
+
+foreach simd_kwargs : simd_variants
+
+  if host_machine.cpu_family() == 'arm' and 'neon' in simd_kwargs
+    if not cc.compiles('''
+        #include <arm_neon.h>
+        int main() {
+            return sizeof(uint8x8_t) + sizeof(int32x4_t) + sizeof(float32x4_t);
+        }
+        ''', name : 'neon code')
+      continue
+    endif
+  endif
+
+  libpulsecore_simd = simd.check('libpulsecore_simd',
+    kwargs : simd_kwargs,
+    c_args : [pa_c_args],
+    include_directories : [configinc, topinc],
+    implicit_include_directories : false,
+    compiler : cc)
+
+  libpulsecore_simd_lib += libpulsecore_simd[0]
+  cdata.merge_from(libpulsecore_simd[1])
+endforeach
 
 # FIXME: Implement Windows support
 #'mutex-win32.c',