1
0
mirror of https://github.com/systemd/systemd synced 2024-07-08 20:15:55 +00:00

meson: use bpftool based strip when available

This should be useable in bpftool v5.13 or newer based on:
d80b2fcbe0
This commit is contained in:
James Hilliard 2022-01-30 21:47:38 -07:00 committed by Yu Watanabe
parent 408832e603
commit e3759ac43a
2 changed files with 40 additions and 18 deletions

View File

@ -1012,23 +1012,35 @@ else
clang_supports_bpf = false
endif
if not meson.is_cross_build() and clang_found
llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
check : true).stdout().strip()
else
llvm_strip_bin = 'llvm-strip'
endif
llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
# 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' subcommand, it was added by 985ead416df39d6fe8e89580cc1db6aa273e0175 (v5.6).
bpftool = find_program('bpftool',
'/usr/sbin/bpftool',
required : bpf_framework_required,
version : '>= 5.6')
required : false,
version : '>= 5.13.0')
deps_found = clang_found and clang_supports_bpf and clang_supports_flags and llvm_strip.found() and bpftool.found()
if bpftool.found()
bpftool_strip = true
else
bpftool_strip = false
bpftool = find_program('bpftool',
'/usr/sbin/bpftool',
required : bpf_framework_required,
version : '>= 5.6.0')
endif
if not bpftool_strip
if not meson.is_cross_build() and clang_found
llvm_strip_bin = run_command(clang, '--print-prog-name', 'llvm-strip',
check : true).stdout().strip()
else
llvm_strip_bin = 'llvm-strip'
endif
llvm_strip = find_program(llvm_strip_bin, required : bpf_framework_required, version : '>= 10.0.0')
endif
deps_found = clang_found and clang_supports_bpf and clang_supports_flags and (bpftool_strip or llvm_strip.found()) and bpftool.found()
# Can build BPF program from source code in restricted C
conf.set10('BPF_FRAMEWORK', deps_found)

View File

@ -65,13 +65,23 @@ bpf_o_unstripped_cmd += [
'@OUTPUT@'
]
bpf_o_cmd = [
llvm_strip,
'-g',
'@INPUT@',
'-o',
'@OUTPUT@'
]
if bpftool_strip
bpf_o_cmd = [
bpftool,
'g',
'o',
'@OUTPUT@',
'@INPUT@'
]
else
bpf_o_cmd = [
llvm_strip,
'-g',
'@INPUT@',
'-o',
'@OUTPUT@'
]
endif
skel_h_cmd = [
bpftool,