From 54a632f018d94b4616a34298ab148a45edf49841 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Mon, 30 Dec 2024 16:10:39 -0500 Subject: [PATCH] meson: Convert the 'neon' option into a feature Easier to express things, now that runtime is a no-op. --- meson.build | 24 ++++----------------- meson_options.txt | 4 ++-- webrtc/common_audio/meson.build | 2 +- webrtc/modules/audio_processing/meson.build | 2 +- webrtc/third_party/pffft/meson.build | 6 +----- 5 files changed, 9 insertions(+), 29 deletions(-) diff --git a/meson.build b/meson.build index 37f7e3d..a388189 100644 --- a/meson.build +++ b/meson.build @@ -135,9 +135,7 @@ if host_machine.cpu_family() == 'arm' have_neon = true endif endif -if cc.compiles('''#ifndef __aarch64__ -#error no aarch64 arch -#endif''') +if host_machine.cpu_family() == 'aarch64' have_arm64 = true have_neon = true arch_cflags += ['-DWEBRTC_ARCH_ARM64'] @@ -165,23 +163,9 @@ if ['x86', 'x86_64'].contains(host_machine.cpu_family()) endif endif -neon_opt = get_option('neon') -if neon_opt == 'auto' - if have_arm64 - neon_opt = 'yes' - elif have_neon - neon_opt = 'runtime' - else - neon_opt = 'no' - endif -endif -if neon_opt != 'no' and not have_neon - error('Compiler or architecture does not support NEON') -endif -if neon_opt == 'runtime' - warning('webrtc cannot check NEON support at runtime, will build without NEON') -endif -if neon_opt == 'yes' +neon_opt = get_option('neon').require(have_neon) + +if neon_opt.enabled() arch_cflags += ['-DWEBRTC_HAS_NEON'] if not have_arm64 arch_cflags += ['-mfpu=neon'] diff --git a/meson_options.txt b/meson_options.txt index 45c4bfb..9c8815e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,8 +1,8 @@ option('gnustl', type: 'feature', value: 'auto', description: 'Use gnustl for a c++ library implementation (only used on Android)') -option('neon', type: 'combo', - choices: ['auto', 'yes', 'runtime', 'no'], +option('neon', type: 'feature', + value: 'auto', description: 'Enable NEON optimisations') option('inline-sse', type: 'boolean', value: true, diff --git a/webrtc/common_audio/meson.build b/webrtc/common_audio/meson.build index 051e9f3..d38a799 100644 --- a/webrtc/common_audio/meson.build +++ b/webrtc/common_audio/meson.build @@ -112,7 +112,7 @@ if have_armv7 ] endif -if neon_opt == 'yes' +if neon_opt.enabled() common_audio_sources += [ 'fir_filter_neon.cc', 'resampler/sinc_resampler_neon.cc', diff --git a/webrtc/modules/audio_processing/meson.build b/webrtc/modules/audio_processing/meson.build index e8b04b9..78fc970 100644 --- a/webrtc/modules/audio_processing/meson.build +++ b/webrtc/modules/audio_processing/meson.build @@ -180,7 +180,7 @@ else ] endif -if neon_opt == 'yes' +if neon_opt.enabled() webrtc_audio_processing_sources += [ 'aecm/aecm_core_neon.cc', ] diff --git a/webrtc/third_party/pffft/meson.build b/webrtc/third_party/pffft/meson.build index 28707d2..c9e14a1 100644 --- a/webrtc/third_party/pffft/meson.build +++ b/webrtc/third_party/pffft/meson.build @@ -4,11 +4,7 @@ pffft_sources = [ pffft_cflags = [ '-D_GNU_SOURCE' ] -if neon_opt == 'runtime' - warning('pffft cannot check NEON support at runtime, will build without NEON') -endif - -if not have_inline_sse or (have_arm and neon_opt != 'yes') or (have_mips and host_machine.endian() == 'little') or have_mips64 +if not have_inline_sse or (have_arm and not neon_opt.enabled()) or (have_mips and host_machine.endian() == 'little') or have_mips64 pffft_cflags += [ '-DPFFFT_SIMD_DISABLE' ] endif