summaryrefslogtreecommitdiffstats
path: root/meson.build
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2024-09-30 17:56:18 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2024-10-01 22:08:06 +0200
commit608009dc6218f7c41420f665586f2449b64a08f7 (patch)
tree2353908f4bba626a99b88f5874264d29c8816a9d /meson.build
parentRevert "Preset user units on first boot as well" (diff)
downloadsystemd-608009dc6218f7c41420f665586f2449b64a08f7.tar.xz
systemd-608009dc6218f7c41420f665586f2449b64a08f7.zip
bpf: fix cross build failure on Debian
For compiling bpf code, the system include directory needs to be constructed. On Debian-like systems, this requires passing a multiarch directory. Since clang's -dump-machine prints something other that the multiarch triplet, gcc was interrogated earlier, but that also yields a wrong result for cross compilation and was thus skipped resulting in clang not finding asm/types.h. Rather than, -dump-machine we should ask for -print-multiarch (which rarely differs). Whenever gcc is in use, this is right (even for cross building). Since clang does not support -print-multiarch and its -dump-machine never matches Debian's multiarch, we resort to asking gcc when building natively. For cross builds using clang, we are out of luck.
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build23
1 files changed, 15 insertions, 8 deletions
diff --git a/meson.build b/meson.build
index 6d96996acb..724c48adc8 100644
--- a/meson.build
+++ b/meson.build
@@ -1823,15 +1823,22 @@ if conf.get('BPF_FRAMEWORK') == 1
bpf_o_unstripped_cmd += ['-I.']
- if not meson.is_cross_build()
- target_triplet_cmd = run_command('gcc', '-dumpmachine', check: false)
- if target_triplet_cmd.returncode() == 0
- target_triplet = target_triplet_cmd.stdout().strip()
- bpf_o_unstripped_cmd += [
- '-isystem',
- '/usr/include/@0@'.format(target_triplet)
- ]
+ if cc.get_id() == 'gcc' or meson.is_cross_build()
+ if cc.get_id() != 'gcc'
+ warning('Cross compiler is not gcc. Guessing the target triplet for bpf likely fails.')
endif
+ target_triplet_cmd = run_command(cc.cmd_array(), '-print-multiarch', check: false)
+ else
+ # clang does not support -print-multiarch (D133170) and its -dump-machine
+ # does not match multiarch. Query gcc instead.
+ target_triplet_cmd = run_command('gcc', '-print-multiarch', check: false)
+ endif
+ if target_triplet_cmd.returncode() == 0
+ target_triplet = target_triplet_cmd.stdout().strip()
+ bpf_o_unstripped_cmd += [
+ '-isystem',
+ '/usr/include/@0@'.format(target_triplet)
+ ]
endif
bpf_o_unstripped_cmd += [