From 8b0255991e719eaa8a5b5fac0ad877ee72e7aae3 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Wed, 30 Oct 2024 02:09:14 +0300 Subject: [PATCH] meson: Set WEBRTC_HAS_NEON macro after handling neon build option The WEBRTC_HAS_NEON macro that enables using NEON implementations is unconditionally set for arm64 and the 'neon' build option is ignored, assuming we always want to use the NEON-specific implementations instead of generic ones. This is an OK assumption to make because arm64 CPUs always support NEON. But the code handling the build option ended up quite convoluted. As part of cleaning up, set the relevant cflags after we handle the build option. This also means that we can make 'runtime' fall back to 'no', and disable NEON-specific code with -Dneon=no. Signed-off-by: Alper Nebi Yasak --- meson.build | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 10e6f4e..52f738b 100644 --- a/meson.build +++ b/meson.build @@ -111,6 +111,7 @@ endif arch_cflags = [] have_arm = false have_armv7 = false +have_arm64 = false have_neon = false have_mips = false have_mips64 = false @@ -134,8 +135,9 @@ endif if cc.compiles('''#ifndef __aarch64__ #error no aarch64 arch #endif''') + have_arm64 = true have_neon = true - arch_cflags += ['-DWEBRTC_ARCH_ARM64', '-DWEBRTC_HAS_NEON'] + arch_cflags += ['-DWEBRTC_ARCH_ARM64'] endif if ['mips', 'mips64'].contains(host_machine.cpu_family()) have_mips = true @@ -164,7 +166,6 @@ neon_opt = get_option('neon') if neon_opt != 'no' and not have_neon if neon_opt != 'runtime' if cc.compiles('#include ', args : '-mfpu=neon') - arch_cflags += ['-mfpu=neon', '-DWEBRTC_HAS_NEON'] have_neon = true endif endif @@ -173,6 +174,12 @@ if neon_opt == 'runtime' warning('webrtc cannot check NEON support at runtime, will build without NEON') have_neon = false endif +if have_neon + arch_cflags += ['-DWEBRTC_HAS_NEON'] + if not have_arm64 + arch_cflags += ['-mfpu=neon'] + endif +endif common_cflags = [ '-DWEBRTC_LIBRARY_IMPL',