diff mbox series

[v1,2/2] systemd: bpf-framework: pass STAGING_INCDIR to eBPF compiler

Message ID 20240609084321.1070686-1-johannes.schneider@leica-geosystems.com
State New
Headers show
Series None | expand

Commit Message

SCHNEIDER Johannes June 9, 2024, 8:43 a.m. UTC
The eBPFs are pre-compiled during the systemd-build with a different
compiler than the cross-compiler used to build systemd itself.

This is either a 'clang-native' or a gcc (bpf-unknown-none) which do
not see the BUILD_CFLAGS set -isystem ${STAGING_INCDIR}. For this the
meson.build file constructing the compiler call had to be patched to
handle this bitbake specific setup.

Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
---
 ...bitbake-pass-STAGING_INCDIR-to-clang.patch | 42 +++++++++++++++++++
 meta/recipes-core/systemd/systemd_255.6.bb    |  1 +
 2 files changed, 43 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd/0023-bitbake-pass-STAGING_INCDIR-to-clang.patch
diff mbox series

Patch

diff --git a/meta/recipes-core/systemd/systemd/0023-bitbake-pass-STAGING_INCDIR-to-clang.patch b/meta/recipes-core/systemd/systemd/0023-bitbake-pass-STAGING_INCDIR-to-clang.patch
new file mode 100644
index 0000000000..a6d4d7a81d
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0023-bitbake-pass-STAGING_INCDIR-to-clang.patch
@@ -0,0 +1,42 @@ 
+From 4f4b3d662e5475b375808cea3a6a90d61b6c9522 Mon Sep 17 00:00:00 2001
+From: Johannes Schneider <johannes.schneider@leica-geosystems.com>
+Date: Sat, 8 Jun 2024 18:19:39 +0200
+Subject: [PATCH] bitbake: pass STAGING_INCDIR to clang
+
+Pass bitbakes STAGING_INCDIR as header searchpath to clang/gcc, where
+it can&should look for the libbpf headers when it compiles the BPFs.
+
+This is "the least ugly hack", compared to other alternatives like for example
+what '-Defi-includedir=...' did (creating an extra option to smuggle in bitbake
+variables).
+
+Ideally the compiler would use the BUILD_CFLAGS set by bitbake, which
+set among other things also the corretc -isystem...; but haven't found
+a good way to do so in meson (yet) :-P
+
+Upstream-Status: Inappropriate [oe specific]
+Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
+---
+ meson.build | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index 187e7b216d..dc1a464504 100644
+--- a/meson.build
++++ b/meson.build
+@@ -1746,7 +1746,11 @@ if conf.get('BPF_FRAMEWORK') == 1
+ 
+         bpf_o_unstripped_cmd += ['-I.']
+ 
+-        if not meson.is_cross_build()
++        if meson.is_cross_build()
++                ## point 'clang'/'gcc' to the bitbake recipe sysroot, to find the libbpf headers there.
++                staging_incdir = join_paths(meson.source_root(), '../recipe-sysroot/usr/include')
++                bpf_o_unstripped_cmd += [ '-isystem', staging_incdir ]
++        else
+                 target_triplet_cmd = run_command('gcc', '-dumpmachine', check: false)
+                 if target_triplet_cmd.returncode() == 0
+                         target_triplet = target_triplet_cmd.stdout().strip()
+-- 
+2.34.1
+
diff --git a/meta/recipes-core/systemd/systemd_255.6.bb b/meta/recipes-core/systemd/systemd_255.6.bb
index e70c9c738d..3fd4d5bc5b 100644
--- a/meta/recipes-core/systemd/systemd_255.6.bb
+++ b/meta/recipes-core/systemd/systemd_255.6.bb
@@ -28,6 +28,7 @@  SRC_URI += " \
            file://systemd-pager.sh \
            file://0002-binfmt-Don-t-install-dependency-links-at-install-tim.patch \
            file://0008-implment-systemd-sysv-install-for-OE.patch \
+           file://0023-bitbake-pass-STAGING_INCDIR-to-clang.patch \
            "
 
 # patches needed by musl