From: "'Isaac True' via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com
Cc: Isaac True <itrue@emlix.com>
Subject: [PATCH v2 1/2] linux-custom: add linux-tools package and build perf
Date: Wed, 26 Nov 2025 14:02:28 +0100 [thread overview]
Message-ID: <20251126130534.3484253-3-itrue@emlix.com> (raw)
In-Reply-To: <20251126130534.3484253-2-itrue@emlix.com>
Add an additional package to the linux-custom recipe which can be used
to deliver tools built from the kernel sources.
Additionally, 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/control.tmpl | 10 ++++++++++
meta/recipes-kernel/linux/files/debian/isar/build.tmpl | 3 +++
.../recipes-kernel/linux/files/debian/isar/common.tmpl | 2 ++
.../linux/files/debian/isar/install.tmpl | 7 +++++++
meta/recipes-kernel/linux/files/debian/rules.tmpl | 2 +-
meta/recipes-kernel/linux/linux-custom.inc | 10 ++++++++++
6 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/meta/recipes-kernel/linux/files/debian/control.tmpl b/meta/recipes-kernel/linux/files/debian/control.tmpl
index ee87cf92..edb3960a 100644
--- a/meta/recipes-kernel/linux/files/debian/control.tmpl
+++ b/meta/recipes-kernel/linux/files/debian/control.tmpl
@@ -69,3 +69,13 @@ Conflicts: linux-kbuild-${KERNEL_NAME_PROVIDED}
Description: ${KERNEL_NAME_PROVIDED} Linux kbuild scripts and tools for @KR@
This package provides kernel kbuild scripts and tools for @KR@
This is useful for people who need to build external modules
+
+Package: linux-tools-${KERNEL_NAME_PROVIDED}
+Build-Profiles: <pkg.${BPN}.kernel pkg.${BPN}.tools>
+Architecture: any
+Multi-Arch: foreign
+Depends: ${misc:Depends}, ${shlib:Depends}
+Description: ${KERNEL_NAME_PROVIDED} Linux tools for @KR@
+ This package provides kernel tools for @KR@.
+ .
+ This is useful for people who want to run things like perf.
diff --git a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl
index b4c105c1..72edfa42 100644
--- a/meta/recipes-kernel/linux/files/debian/isar/build.tmpl
+++ b/meta/recipes-kernel/linux/files/debian/isar/build.tmpl
@@ -23,6 +23,9 @@ 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}"
+ if echo "${DEB_BUILD_PROFILES}" | grep -q "tools"; then # Build kernel tools
+ ${MAKE} O=${KERNEL_BUILD_DIR} ${PARALLEL_MAKE} ${KERNEL_EXTRA_BUILDARGS} KCFLAGS="${KCFLAGS}" KAFLAGS="${KAFLAGS}" -C tools/perf
+ fi
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/common.tmpl b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl
index f9cc2f02..a104784a 100644
--- a/meta/recipes-kernel/linux/files/debian/isar/common.tmpl
+++ b/meta/recipes-kernel/linux/files/debian/isar/common.tmpl
@@ -12,6 +12,7 @@ KERNEL_PKG_LIBC_HEADERS=linux-libc-dev
KERNEL_PKG_LIBC_HEADERS_CROSS=linux-libc-dev-${DISTRO_ARCH}-cross
KERNEL_PKG_KERN_KBUILD=linux-kbuild-${KERNEL_NAME_PROVIDED}
KERNEL_PKG_KERN_KBUILD_CROSS=${KERNEL_PKG_KERN_KBUILD}-${DISTRO_ARCH}-cross
+KERNEL_PKG_TOOLS=linux-tools-${KERNEL_NAME_PROVIDED}
# Force creating debian package with valid host arch for -native build
# Use a cross build to comply with arch specific kernel defconfigs
@@ -38,6 +39,7 @@ deb_libc_hdr_dir=${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS}
deb_libc_hdr_cross_dir=${deb_top_dir}/${KERNEL_PKG_LIBC_HEADERS_CROSS}
deb_kern_kbuild_dir=${deb_top_dir}/${KERNEL_PKG_KERN_KBUILD}
deb_kern_kbuild_cross_dir=${deb_top_dir}/${KERNEL_PKG_KERN_KBUILD_CROSS}
+deb_tools_dir=${deb_top_dir}/${KERNEL_PKG_TOOLS}
# Array of packages to be generated
declare -A kern_pkgs
diff --git a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl
index 6fa94508..76d238a0 100644
--- a/meta/recipes-kernel/linux/files/debian/isar/install.tmpl
+++ b/meta/recipes-kernel/linux/files/debian/isar/install.tmpl
@@ -68,6 +68,9 @@ do_install() {
install_dtbs
install_kmods
install_headers
+ if echo "${DEB_BUILD_PROFILES}" | grep -q "tools"; then
+ install_tools
+ fi
fi
# Stop tracing
@@ -137,6 +140,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
diff --git a/meta/recipes-kernel/linux/linux-custom.inc b/meta/recipes-kernel/linux/linux-custom.inc
index ccbea976..df862ef3 100644
--- a/meta/recipes-kernel/linux/linux-custom.inc
+++ b/meta/recipes-kernel/linux/linux-custom.inc
@@ -169,6 +169,14 @@ RECIPE_PROVIDES:append:libcdev = " \
linux-libc-dev-${DISTRO_ARCH}-cross \
"
+# Set to "1" to enable the tools build profile and build the linux-tools package
+KERNEL_BUILD_TOOLS ??= "0"
+
+# Provide the linux-tools package if the tools build profile has been enabled
+RECIPE_PROVIDES:append = " \
+ ${@ bb.utils.contains('DEB_BUILD_PROFILES', 'pkg.{}.tools'.format(d.getVar('BPN')), 'linux-tools-{}'.format(d.getVar('KERNEL_NAME_PROVIDED')), '', d)} \
+"
+
# When cross-profile is active:
# kbuild package is provided by -native or -kbuildtarget variant. Also headers
# provisioning moves over to ensure those variants are pulled, although the
@@ -231,6 +239,8 @@ def get_additional_build_profiles(d):
profiles += ' pkg.{}.nolibcdev'.format(d.getVar('BPN'))
elif bb.utils.to_boolean(d.getVar('KERNEL_LIBC_DEV_ARCH_ALL')):
profiles += ' pkg.{}.libcdev-arch-all'.format(d.getVar('BPN'))
+ if bb.utils.to_boolean(d.getVar('KERNEL_BUILD_TOOLS')):
+ profiles += ' pkg.{}.tools'.format(d.getVar('BPN'))
return profiles
KERNEL_LIBC_DEV_ARCH = "${@ bb.utils.contains('DEB_BUILD_PROFILES', 'pkg.{}.libcdev-arch-all'.format(d.getVar('BPN')), 'all\nMulti-Arch: foreign', 'any', d) }"
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20251126130534.3484253-3-itrue%40emlix.com.
next prev parent reply other threads:[~2025-11-26 13:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 13:02 [PATCH v2 0/2] linux-custom: add linux-tools package and perf 'Isaac True' via isar-users
2025-11-26 13:02 ` 'Isaac True' via isar-users [this message]
2025-11-27 7:22 ` [PATCH v2 1/2] linux-custom: add linux-tools package and build perf 'Jan Kiszka' via isar-users
2025-11-26 13:02 ` [PATCH v2 2/2] doc: custom_kernel: add perf and linux-tools 'Isaac True' via isar-users
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251126130534.3484253-3-itrue@emlix.com \
--to=isar-users@googlegroups.com \
--cc=itrue@emlix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox