]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: use bpftool based strip when available
authorJames Hilliard <james.hilliard1@gmail.com>
Mon, 31 Jan 2022 04:47:38 +0000 (21:47 -0700)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 31 Jan 2022 07:42:07 +0000 (16:42 +0900)
This should be useable in bpftool v5.13 or newer based on:
https://github.com/torvalds/linux/commit/d80b2fcbe0a023619e0fc73112f2a02c2662f6ab

meson.build
src/core/bpf/meson.build

index 43c3252e3611817967383768121926727c78467a..b8b01e0deb7a4b2c62e7270177c464f17ce34b61 100644 (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')
+
+        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 llvm_strip.found() and bpftool.found()
+        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)
index c2465a845f44c7a64ab183c9a95cecb667545f04..57a4c5393c90737bbb7888473f1dde789db4e050 100644 (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,