diff mbox series

kernel-devsrc: Install sources required for BPF host tools

Message ID 20260731043628.1566-1-wangmy@fujitsu.com
State Under Review
Headers show
Series kernel-devsrc: Install sources required for BPF host tools | expand

Commit Message

Wang Mingyu July 31, 2026, 4:36 a.m. UTC
From: Wang Mingyu <wangmy@fujitsu.com>

When CONFIG_DEBUG_INFO_BTF is enabled in the kernel, building external
modules that use BPF requires the 'resolve_btfids' host tool. This tool
and its dependencies were not included in the kernel-devsrc package.
 
This can cause a build failure in an SDK environment when 'make scripts'
is run, for example:
 
  make[4]: *** No rule to make target '.../tools/bpf/resolve_btfids/main.o'
 
To fix this, unconditionally install the minimal set of source files
required to build the 'resolve_btfids' tool and its library dependencies.
This avoids coupling the recipe to specific kernel CONFIG symbols while
also ensuring only necessary files are included in the package.
 
The copy operations ignore errors to prevent build failures on older
kernel versions where these files may not exist.

Signed-off-by: Wang Mingyu <wangmy@fujitsu.com>
---
V1: https://lists.openembedded.org/g/openembedded-core/message/242225
Changes in v2:
  - Remove conditional copy based on CONFIG_DEBUG_INFO_BTF.
  - Copy a minimal set of files instead of entire directories.
  - Make copy operations robust against non-existent files.

---
 meta/recipes-kernel/linux/kernel-devsrc.bb | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb b/meta/recipes-kernel/linux/kernel-devsrc.bb
index 237dec6b12..ca1a08cba3 100644
--- a/meta/recipes-kernel/linux/kernel-devsrc.bb
+++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
@@ -176,6 +176,18 @@  do_install() {
             cp -a --parents $(find tools/arch/${ARCH}/ -type f) $kerneldir/build/
         fi
 
+        # For v5.2+ when BTF is enabled, scripts prepare may rebuild the
+        # resolve_btfids host tool. Copy the minimal sources it needs instead
+        # of coupling this recipe to a specific kernel CONFIG_ symbol.
+        cp -a --parents tools/bpf/resolve_btfids/* $kerneldir/build/ 2>/dev/null || :
+        cp -a --parents tools/lib/bpf/* $kerneldir/build/ 2>/dev/null || :
+        cp -a --parents tools/lib/subcmd/* $kerneldir/build/ 2>/dev/null || :
+        cp -a --parents tools/lib/ctype.c tools/lib/rbtree.c tools/lib/str_error_r.c \
+            tools/lib/string.c tools/lib/zalloc.c $kerneldir/build/ 2>/dev/null || :
+        cp -a --parents tools/build/Build.include tools/build/Build tools/build/fixdep.c \
+            tools/scripts/Makefile.arch tools/scripts/Makefile.include \
+            tools/scripts/utilities.mak $kerneldir/build/ 2>/dev/null || :
+
         if [ "${ARCH}" = "arm64" ]; then
             # arch/arm64/include/asm/xen references arch/arm
             cp -a --parents arch/arm/include/asm/xen $kerneldir/build/