From: Wang Mingyu <[email protected]>

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 <[email protected]>
---
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 --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/
-- 
2.43.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#242391): 
https://lists.openembedded.org/g/openembedded-core/message/242391
Mute This Topic: https://lists.openembedded.org/mt/120530366/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to