diff mbox series

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

Message ID 20240609080856.1020300-3-johannes.schneider@leica-geosystems.com
State New
Headers show
Series systemd and RestrictNetworkInterfaces | expand

Commit Message

SCHNEIDER Johannes June 9, 2024, 8:08 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 | 41 +++++++++++++++++++
 meta/recipes-core/systemd/systemd_255.6.bb    |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd/0023-bitbake-pass-STAGING_INCDIR-to-clang.patch

Comments

patchtest@automation.yoctoproject.org June 9, 2024, 8:21 a.m. UTC | #1
Thank you for your submission. Patchtest identified one
or more issues with the patch. Please see the log below for
more information:

---
Testing patch /home/patchtest/share/mboxes/v1-2-2-systemd-bpf-framework-pass-STAGING_INCDIR-to-eBPF-compiler.patch

FAIL: test Upstream-Status presence: Added patch file is missing Upstream-Status: <Valid status> in the commit message (test_patch.TestPatch.test_upstream_status_presence_format)

PASS: test CVE tag format (test_patch.TestPatch.test_cve_tag_format)
PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test Signed-off-by presence (test_patch.TestPatch.test_signed_off_by_presence)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: pretest src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.pretest_src_uri_left_files)
SKIP: test CVE check ignore: No modified recipes or older target branch, skipping test (test_metadata.TestMetadata.test_cve_check_ignore)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum modified not mentioned: No modified recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.test_src_uri_left_files)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)
SKIP: test target mailing list: Series merged, no reason to check other mailing lists (test_mbox.TestMbox.test_target_mailing_list)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this
email with an explanation of why the patch should be accepted. If you
believe these results are due to an error in patchtest, please submit a
bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category
under 'Yocto Project Subprojects'). For more information on specific
failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank
you!
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..b907fd79b7
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0023-bitbake-pass-STAGING_INCDIR-to-clang.patch
@@ -0,0 +1,41 @@ 
+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
+
+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