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 <alpernebiyasak@gmail.com>
This commit is contained in:
Alper Nebi Yasak 2024-10-30 02:09:14 +03:00 committed by Arun Raghavan
parent b22ce018c8
commit 8b0255991e

View File

@ -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 <arm_neon.h>', 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',