]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: check if clang supports bpf
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 13 Jan 2022 06:33:46 +0000 (15:33 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 14 Jan 2022 07:43:31 +0000 (16:43 +0900)
meson.build

index a0ce462f317ddc627e59e12fb3d40e88b0b943dc..073667ef6c9245b5849779c2a6e24a26af2a33b2 100644 (file)
@@ -995,6 +995,14 @@ else
                 clang_bin = 'clang'
         endif
         clang = find_program(clang_bin, required : bpf_framework_required)
+
+        if clang.found()
+                # Check if 'clang -target bpf' is supported.
+                clang_supports_bpf = run_command(clang, '-target', 'bpf', '--print-supported-cpus', check : false).returncode() == 0
+        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()
@@ -1011,7 +1019,7 @@ else
                                required : bpf_framework_required,
                                version : '>= 5.6')
 
-        deps_found = libbpf.found() and clang.found() and llvm_strip.found() and bpftool.found()
+        deps_found = libbpf.found() and clang.found() and clang_supports_bpf and llvm_strip.found() and bpftool.found()
         # Can build BPF program from source code in restricted C
         conf.set10('BPF_FRAMEWORK', deps_found)
 endif