From 847e5585b6784160546c6a6cb1ca2471a459f926 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Thu, 10 Aug 2023 16:33:37 +0200 Subject: [PATCH] meson: Convert bpf-framework to meson feature --- meson.build | 34 ++++++++++++++-------------------- meson_options.txt | 2 +- mkosi.presets/base/mkosi.build | 2 +- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/meson.build b/meson.build index bdf6b7b43d..5a36f140a2 100644 --- a/meson.build +++ b/meson.build @@ -1027,23 +1027,14 @@ foreach ident : [ conf.set10('HAVE_' + ident[0].to_upper(), have) endforeach -want_bpf_framework = get_option('bpf-framework') +bpf_framework = get_option('bpf-framework') bpf_compiler = get_option('bpf-compiler') -bpf_framework_required = want_bpf_framework == 'true' - -libbpf_version_requirement = '>= 0.1.0' -if bpf_compiler == 'gcc' - libbpf_version_requirement = '>= 1.0.0' -endif -libbpf = dependency('libbpf', required : bpf_framework_required, version : libbpf_version_requirement) +libbpf = dependency('libbpf', + required : bpf_framework, + version : bpf_compiler == 'gcc' ? '>= 1.0.0' : '>= 0.1.0') conf.set10('HAVE_LIBBPF', libbpf.found()) -bpftool_strip_version_requirement = '>= 5.13.0' -if bpf_compiler == 'gcc' - bpftool_strip_version_requirement = '>= 7.0.0' -endif - -if want_bpf_framework == 'false' or not libbpf.found() or skip_deps +if not libbpf.found() conf.set10('BPF_FRAMEWORK', false) else clang_found = false @@ -1056,7 +1047,9 @@ else # Support 'versioned' clang/llvm-strip binaries, as seen on Debian/Ubuntu # (like clang-10/llvm-strip-10) if meson.is_cross_build() or cc.get_id() != 'clang' or cc.cmd_array()[0].contains('afl-clang') or cc.cmd_array()[0].contains('hfuzz-clang') - r = find_program('clang', required : bpf_framework_required, version : '>= 10.0.0') + r = find_program('clang', + required : bpf_framework, + version : '>= 10.0.0') clang_found = r.found() if clang_found clang = r.full_path() @@ -1082,11 +1075,10 @@ else # Debian installs this in /usr/sbin/ which is not in $PATH. # We check for 'bpftool' first, honouring $PATH, and in /usr/sbin/ for Debian. # We use 'bpftool gen object' subcommand for bpftool strip, it was added by d80b2fcbe0a023619e0fc73112f2a02c2662f6ab (v5.13). - bpftool_strip_required = bpf_framework_required and bpf_compiler == 'gcc' bpftool = find_program('bpftool', '/usr/sbin/bpftool', - required : bpftool_strip_required, - version : bpftool_strip_version_requirement) + required : bpf_framework.enabled() and bpf_compiler == 'gcc', + version : bpf_compiler == 'gcc' ? '>= 7.0.0' : '>= 5.13.0') if bpftool.found() bpftool_strip = true @@ -1095,7 +1087,7 @@ else # We require the 'bpftool gen skeleton' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6). bpftool = find_program('bpftool', '/usr/sbin/bpftool', - required : bpf_framework_required, + required : bpf_framework, version : '>= 5.6.0') endif @@ -1107,7 +1099,9 @@ else else llvm_strip_bin = 'llvm-strip' endif - llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0') + llvm_strip = find_program(llvm_strip_bin, + required : bpf_framework, + version : '>= 10.0.0') deps_found = llvm_strip.found() endif endif diff --git a/meson_options.txt b/meson_options.txt index 4cdb07ef7b..8dbf9537a1 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -504,7 +504,7 @@ option('analyze', type: 'boolean', value: true, option('bpf-compiler', type : 'combo', choices : ['clang', 'gcc'], description: 'compiler used to build BPF programs') -option('bpf-framework', type : 'combo', choices : ['auto', 'true', 'false'], +option('bpf-framework', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description: 'build BPF programs from source code in restricted C') option('skip-deps', type : 'boolean', value : false, diff --git a/mkosi.presets/base/mkosi.build b/mkosi.presets/base/mkosi.build index c295fa0a19..022b3f2612 100755 --- a/mkosi.presets/base/mkosi.build +++ b/mkosi.presets/base/mkosi.build @@ -146,7 +146,7 @@ if [ ! -f "$BUILDDIR"/build.ninja ]; then -D bootloader=enabled -D kernel-install=true -D analyze=true - -D bpf-framework=true + -D bpf-framework=enabled -D ukify="$UKIFY" -D seccomp=enabled -D selinux=auto