]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: prepend sys_root to bpf isystem
authorJames Hilliard <james.hilliard1@gmail.com>
Mon, 21 Jul 2025 19:04:49 +0000 (13:04 -0600)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 4 Aug 2025 14:46:38 +0000 (15:46 +0100)
These sort of absolute include paths are generally unsafe when cross compiling.

(cherry picked from commit 28575ac014194d0040e38db3e95edc5fb8b4b96b)

meson.build

index 1253f66cde9f01bda26f3b3891d87453b510755a..b11fed9efa99e8fc7dca6db657aa11c9c2d78fe1 100644 (file)
@@ -1863,11 +1863,21 @@ if conf.get('BPF_FRAMEWORK') == 1
                 target_triplet_cmd = run_command('gcc', '-print-multiarch', check: false)
         endif
         if target_triplet_cmd.returncode() == 0
+                sysroot = meson.get_external_property('sys_root', '/')
                 target_triplet = target_triplet_cmd.stdout().strip()
-                bpf_o_unstripped_cmd += [
-                        '-isystem',
-                        '/usr/include/@0@'.format(target_triplet)
-                ]
+                target_include_dir = sysroot / 'usr' / 'include'
+                target_triple_include_dir = target_include_dir / target_triplet
+                isystem_dir = ''
+                if fs.is_dir(target_triple_include_dir)
+                        isystem_dir = target_triple_include_dir
+                elif fs.is_dir(target_include_dir)
+                        isystem_dir = target_include_dir
+                endif
+                if isystem_dir != ''
+                        bpf_o_unstripped_cmd += [
+                                '-isystem', isystem_dir
+                        ]
+                endif
         endif
 
         bpf_o_unstripped_cmd += [