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 live in tools/bpf/ and tools/lib/, but were not
included in the kernel-devsrc package.

This caused a build failure in the SDK when running 'make scripts prepare':

  make[4]: *** No rule to make target '.../tools/bpf/resolve_btfids/main.o'

Copy tools/bpf/ and tools/lib/ into the devsrc build directory when
CONFIG_DEBUG_INFO_BTF=y is detected in the kernel config, matching the
existing pattern for the 'rust' directory and for objtool.

Signed-off-by: Wang Mingyu <[email protected]>
---
 meta/recipes-kernel/linux/kernel-devsrc.bb | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/meta/recipes-kernel/linux/kernel-devsrc.bb 
b/meta/recipes-kernel/linux/kernel-devsrc.bb
index 237dec6b12..23779ed107 100644
--- a/meta/recipes-kernel/linux/kernel-devsrc.bb
+++ b/meta/recipes-kernel/linux/kernel-devsrc.bb
@@ -176,6 +176,19 @@ do_install() {
             cp -a --parents $(find tools/arch/${ARCH}/ -type f) 
$kerneldir/build/
         fi
 
+        # In sdk, when CONFIG_DEBUG_INFO_BTF is enabled, building external 
modules
+        # that use BPF may require the 'resolve_btfids' host tool. This tool
+        # and others require sources from tools/bpf/ and tools/lib/ to be built
+        # within the SDK environment.
+        if grep -q "CONFIG_DEBUG_INFO_BTF=y" ${B}/.config; then
+            echo "NOTE: CONFIG_DEBUG_INFO_BTF is enabled, including BPF host 
tools sources in kernel-devsrc."
+            # The 'rust' example copies the whole dir. We do the same for 
consistency.
+            # This includes resolve_btfids and other potential BPF tools.
+            cp -r tools/bpf ${kerneldir}/build/tools/
+            # This also requires the shared tools/lib directory.
+            cp -r tools/lib ${kerneldir}/build/tools/
+        fi
+
         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 (#242224): 
https://lists.openembedded.org/g/openembedded-core/message/242224
Mute This Topic: https://lists.openembedded.org/mt/120497655/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to