blob: 5d9370fb165a37f9c6b29222a5eadb99b6ec597c [file] [log] [blame]
Andrew Geissler5f350902021-07-23 13:09:54 -04001From 09f846fbdeb19193e778ce51baa77bd03c38372e Mon Sep 17 00:00:00 2001
2From: garrison <garrison@qemu15.qemu-network>
3Date: Fri, 4 Jun 2021 22:13:02 +0000
4Subject: [PATCH] build-sys: meson: check if NEON code can be compiled on arm
5
6When Meson SIMD module returns HAVE_NEON=1 on arm host, do extra compile check
7to verify compiler can actually handle NEON code.
8
9Related Meson issue #6361 https://github.com/mesonbuild/meson/issues/6361
10
11Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/574>
12
13Upstream-Status: Backport[https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/6d2a49a6a1eacc2096d0d9473a074421c181ab56]
14
15Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
16---
17 src/pulsecore/meson.build | 41 +++++++++++++++++++++++++++++----------
18 1 file changed, 31 insertions(+), 10 deletions(-)
19
20diff --git a/src/pulsecore/meson.build b/src/pulsecore/meson.build
21index 99a702e..d0b7990 100644
22--- a/src/pulsecore/meson.build
23+++ b/src/pulsecore/meson.build
24@@ -172,16 +172,37 @@ endif
25
26 # FIXME: SIMD support (ORC)
27 simd = import('unstable-simd')
28-libpulsecore_simd = simd.check('libpulsecore_simd',
29- mmx : ['remap_mmx.c', 'svolume_mmx.c'],
30- sse : ['remap_sse.c', 'sconv_sse.c', 'svolume_sse.c'],
31- neon : ['remap_neon.c', 'sconv_neon.c', 'mix_neon.c'],
32- c_args : [pa_c_args],
33- include_directories : [configinc, topinc],
34- implicit_include_directories : false,
35- compiler : cc)
36-libpulsecore_simd_lib = libpulsecore_simd[0]
37-cdata.merge_from(libpulsecore_simd[1])
38+simd_variants = [
39+ { 'mmx' : ['remap_mmx.c', 'svolume_mmx.c'] },
40+ { 'sse' : ['remap_sse.c', 'sconv_sse.c', 'svolume_sse.c'] },
41+ { 'neon' : ['remap_neon.c', 'sconv_neon.c', 'mix_neon.c'] },
42+]
43+
44+libpulsecore_simd_lib = []
45+
46+foreach simd_kwargs : simd_variants
47+
48+ if host_machine.cpu_family() == 'arm' and 'neon' in simd_kwargs
49+ if not cc.compiles('''
50+ #include <arm_neon.h>
51+ int main() {
52+ return sizeof(uint8x8_t) + sizeof(int32x4_t) + sizeof(float32x4_t);
53+ }
54+ ''', name : 'neon code')
55+ continue
56+ endif
57+ endif
58+
59+ libpulsecore_simd = simd.check('libpulsecore_simd',
60+ kwargs : simd_kwargs,
61+ c_args : [pa_c_args],
62+ include_directories : [configinc, topinc],
63+ implicit_include_directories : false,
64+ compiler : cc)
65+
66+ libpulsecore_simd_lib += libpulsecore_simd[0]
67+ cdata.merge_from(libpulsecore_simd[1])
68+endforeach
69
70 # FIXME: Implement Windows support
71 #'mutex-win32.c',