[2/3] linux-custom: build perf and add it to linux-tools

Message ID 20251126090202.3091051-7-itrue@emlix.com
State Superseded
Headers show
Series linux-custom: add linux-tools package and perf | expand

Commit Message

Isaac True Nov. 26, 2025, 8:59 a.m. UTC
Build the perf tool as part of the kernel build process and add it to
the linux-tools package, allowing users to install it to their target
rootfs.

Signed-off-by: Isaac True <itrue@emlix.com>
---
 meta/recipes-kernel/linux/files/debian/isar/build.tmpl   | 1 +
 meta/recipes-kernel/linux/files/debian/isar/install.tmpl | 5 +++++
 meta/recipes-kernel/linux/files/debian/rules.tmpl        | 2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)

Comments

Isaac True Nov. 26, 2025, 9:09 a.m. UTC | #1
Regarding this line:

> +	unset DEB_HOST_GNU_TYPE && dh_strip -Xvmlinu -Xperf --no-automatic-dbgsym

`-Xperf` is needed when cross-compiling otherwise `dh_strip` complains 
about not understanding the binary type. I assume that this is due to 
unsetting `DEB_HOST_GNU_TYPE` before calling `dh_strip`, but I wasn't 
sure what the reason behind that is, so I just added it to the exclusion 
list. If this should be handled different please let me know and I'll 
make a v2.

Patch

diff --git a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl
index b4c105c1..e8d692d5 100644
--- a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl
+++ b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl
@@ -23,6 +23,7 @@  do_build() {
 
     if echo "${DEB_BUILD_PROFILES}" | grep -q "kernel"; then # Build kernel scripts and tools
         ${MAKE} O=${KERNEL_BUILD_DIR} ${PARALLEL_MAKE} ${KERNEL_EXTRA_BUILDARGS} KCFLAGS="${KCFLAGS}" KAFLAGS="${KAFLAGS}"
+        ${MAKE} O=${KERNEL_BUILD_DIR} ${PARALLEL_MAKE} ${KERNEL_EXTRA_BUILDARGS} KCFLAGS="${KCFLAGS}" KAFLAGS="${KAFLAGS}" -C tools/perf
     elif echo "${DEB_BUILD_PROFILES}" | grep -q "kbuild"; then # Build kernel scripts and tools
         ${MAKE} O=${KERNEL_BUILD_DIR} ${PARALLEL_MAKE} ${KERNEL_EXTRA_BUILDARGS} KCFLAGS="${KCFLAGS}" KAFLAGS="${KAFLAGS}" scripts
         if grep -q -E "CONFIG_STACK_VALIDATION=y|CONFIG_HAVE_OBJTOOL=y" ${KERNEL_BUILD_DIR}/.config && [ -d "tools/objtool" ]; then
diff --git a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl
index a1b00d39..74678249 100644
--- a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl
+++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl
@@ -68,6 +68,7 @@  do_install() {
         install_dtbs
         install_kmods
         install_headers
+        install_tools
     fi
 
     # Stop tracing
@@ -137,6 +138,10 @@  install_dtbs() {
     ${MAKE} O=${O} INSTALL_DTBS_PATH=${deb_img_dir}/usr/lib/linux-image-${krel} dtbs_install
 }
 
+install_tools() {
+    install -Dm0755 ${O}/perf ${deb_tools_dir}/usr/bin/perf
+}
+
 install_kmods() {
     [ -n "${CONFIG_MODULES}" ] || return 0
     ${MAKE} O=${O} modules_install \
diff --git a/meta/recipes-kernel/linux/files/debian/rules.tmpl b/meta/recipes-kernel/linux/files/debian/rules.tmpl
index 598ae93f..a3b25396 100755
--- a/meta/recipes-kernel/linux/files/debian/rules.tmpl
+++ b/meta/recipes-kernel/linux/files/debian/rules.tmpl
@@ -45,4 +45,4 @@  override_dh_strip_nondeterminism:
 	true
 
 override_dh_strip:
-	unset DEB_HOST_GNU_TYPE && dh_strip -Xvmlinu --no-automatic-dbgsym
+	unset DEB_HOST_GNU_TYPE && dh_strip -Xvmlinu -Xperf --no-automatic-dbgsym