Skip to contentSkip to conversation

kernel-devsrc: include tools needed for BTF when enabled

PATCH In review Wang Mingyu 2 participants 2 messages Jul 29

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel-devsrc: include tools needed for BTF when enabled

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.

---
 meta/recipes-kernel/linux/kernel-devsrc.bb | 13 +++++++++++++
 1 file changed, 13 insertions(+)
meta/recipes-kernel/linux/kernel-devsrc.bb +13 -0
index 237dec6b12..23779ed107 100644
@@ -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/
Signature · 1 line
2.43.0
#1 lore raw
Quoted 26 lines · wangmy via lists.openembedded.org

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.

---
 meta/recipes-kernel/linux/kernel-devsrc.bb | 13 +++++++++++++
 1 file changed, 13 insertions(+)
meta/recipes-kernel/linux/kernel-devsrc.bb +0 -0
index 237dec6b12..23779ed107 100644

meta/recipes-kernel/linux/kernel-devsrc.bb do_install() { · line 183

Quoted 8 lines
meta/recipes-kernel/linux/kernel-devsrc.bb +5 -0
@@ -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

You need to find another way to make this conditional, or if the files are small, just copy them over.

kernel devsrc cannot grep and be coupled to specific CONFIG_ symbols.

meta/recipes-kernel/linux/kernel-devsrc.bb do_install() { · line 189

Quoted 6 lines
meta/recipes-kernel/linux/kernel-devsrc.bb +6 -0
+            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/

What does it actually use from those directories? We avoid complete copies whenever possible. Rarely are all the files needed.

Bruce

Quoted 17 lines
meta/recipes-kernel/linux/kernel-devsrc.bb +2 -1
+        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/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II