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, that point to the correct include search
patch. To address this have systemd's meson.build "propagate" the
--system from the C_FLAGS into the BPF compiler call.

Signed-off-by: Johannes Schneider <johannes.schnei...@leica-geosystems.com>
---
 ...pagate-sysroot-for-cross-compilation.patch | 31 +++++++++++++++++++
 meta/recipes-core/systemd/systemd_255.6.bb    |  1 +
 2 files changed, 32 insertions(+)
 create mode 100644 
meta/recipes-core/systemd/systemd/0023-meson-bpf-propagate-sysroot-for-cross-compilation.patch

diff --git 
a/meta/recipes-core/systemd/systemd/0023-meson-bpf-propagate-sysroot-for-cross-compilation.patch
 
b/meta/recipes-core/systemd/systemd/0023-meson-bpf-propagate-sysroot-for-cross-compilation.patch
new file mode 100644
index 0000000000..e8116b0540
--- /dev/null
+++ 
b/meta/recipes-core/systemd/systemd/0023-meson-bpf-propagate-sysroot-for-cross-compilation.patch
@@ -0,0 +1,31 @@
+From 7463b382bcaf26aacc60b73f98f0262aa41db3ee Mon Sep 17 00:00:00 2001
+From: Johannes Schneider <johannes.schnei...@leica-geosystems.com>
+Date: Thu, 20 Jun 2024 12:32:18 +0200
+Subject: [PATCH] meson: bpf: propagate 'sysroot' for cross compilation
+
+During cross-compilation of systemd, the compiler used to build the bpf's needs
+to be pointed at the correct include searchpath. Which can be done by passing
+the corresponding directory in through the cflags; for example in yocto/bitbake
+this would work: CFLAGS += "--sysroot=${STAGING_DIR_TARGET}"
+
+Upstream-Status: Submitted [https://github.com/systemd/systemd/pull/33427]
+Signed-off-by: Johannes Schneider <johannes.schnei...@leica-geosystems.com>
+---
+ meson.build | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/meson.build b/meson.build
+index 187e7b216d..15df058ab6 100644
+--- a/meson.build
++++ b/meson.build
+@@ -1691,6 +1691,7 @@ if conf.get('BPF_FRAMEWORK') == 1
+                 '-ffile-prefix-map=',
+                 '-fdebug-prefix-map=',
+                 '-fmacro-prefix-map=',
++                '--sysroot=',
+         ]
+ 
+         foreach opt : c_args
+-- 
+2.34.1
+
diff --git a/meta/recipes-core/systemd/systemd_255.6.bb 
b/meta/recipes-core/systemd/systemd_255.6.bb
index defdb15620..d2c5e09697 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-meson-bpf-propagate-sysroot-for-cross-compilation.patch 
\
            "
 
 # patches needed by musl
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#200949): 
https://lists.openembedded.org/g/openembedded-core/message/200949
Mute This Topic: https://lists.openembedded.org/mt/106778249/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to