packages/linux-tools: perf: allow building perf with libtraceevent
v2 cover packages/linux-tools: perf: allow building perf with libtraceevent
Hello,
this series is the v2 aiming to allow building perf with libtraceevent support, in order to be able for example to manipulate and record uprobes with perf.
This new revision gets a new commit enforcing PKG_CONFIG_LIBDIR for the perf makefile. I am not sure how I did not get the corresponding error the first time (maybe it needed some full rebuild to trigger), but I now see that I fail to build perf with multiple stable kernels if I do not enforce this variable (if it is not defined, the perf makefile will set it to a value that is wrong in a buildroot build, see [1]). I found a similar thread and attempt (see [2]), this series proposes to implement the second option mentioned in there.
Also, as mentioned in the previous revision, perf may fail to build on some older kernels because the patch correctly setting pkg-config binary name has not been backported. I have identified that only 6.6 needed it (as perf builds start to fail from 6.3, and are fixed in 6.11). The corresponding stable backport request as been sent (see [3])
@Luca: since all stable kernels should get the relevant fix and then allow to build perf with libtraceevent support, I eventually chose _not_ to mention any issue in the Kconfig.
[1] https://elixir.bootlin.com/linux/v6.12.36/source/tools/perf/Makefile.perf#L211
[2] https://lore.kernel.org/buildroot/aBk4au4rQpZJMrTQ@vamoirid-laptop/
[3] https://lore.kernel.org/stable/2025070955-discover-tree-644c@gregkh/T/#m394f2c9392da7cfd3ca130af6a7ec8ff6ee4b6bf
To: [email protected]
Cc: Thomas Petazzoni <[email protected]>
Cc: Luca Ceresoli <[email protected]>
Cc: Olivier Benjamin <[email protected]>
---
Changes in v2:
- enforce PKG_CONFIG_LIBDIR
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Alexis Lothoré (2):
package/linux-tools: perf: build with libtraceevent support when it is selected packages/linux-tools: perf: enforce PKG_CONFIG_LIBDIR
package/linux-tools/linux-tool-perf.mk.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
---
base-commit: f28f34e200bbadf0aea32110c72f7199e65fb0b9
change-id: 20250625-perf_libtraceevent-17e46ee28f90
Best regards,
Signature · 8 lines
Alexis Lothoré, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 1/2 package/linux-tools: perf: build with libtraceevent support when it is selected
When trying to perform a custom uprobe recording on a target with perf built by buildroot, the recording step fails as perf can not record uprobes without libtraceevent support:
$ perf probe -x linked_list insert_name index Target program is compiled without optimization. Skipping prologue. Probe on address 0x808 to force probing at the function entry.
Added new event:
probe_linked_list:insert_name (on insert_name in /root/gdb/linked_list with index)
perf is not linked with libtraceevent, to use the new probe you can use tracefs:
cd /sys/kernel/tracing/
echo 1 > events/probe_linked_list/insert_name/enable
echo 1 > tracing_on
cat trace_pipe
Before removing the probe, echo 0 > events/probe_linked_list/insert_name/enable
$ perf record -e probe_linked_list:insert_name ./linked_list
event syntax error: 'probe_linked_list:insert_name'
\___ unsupported tracepointlibtraceevent is necessary for tracepoint support Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
-e, --event <event> event selector. use 'perf list' to list available events
libtraceevent support for perf has been disabled with commit b4ab45a5c1db ("package/linux-tools: disable libtracevent detection") because there was no libtraceevent package in buildroot to replace the former libtraceevent removed from the kernel sources. Since then, commit 1474f1b34b17 ("package/libtraceevent: new package") has introduced a libtraceevent package. We can then expose again the possibility to build perf with libtraceevent support.
Make buildroot perf makefile detect if libtraceevent package has been enabled, and if so, allow to build perf with libtraceevent support.
---
Changes in v2:
- no change
--- package/linux-tools/linux-tool-perf.mk.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
package/linux-tools/linux-tool-perf.mk.in +6 -1
@@ -28,7 +28,6 @@ PERF_MAKE_FLAGS = \ NO_LIBPERL=1 \ NO_LIBPYTHON=1 \ NO_LIBBIONIC=1 \ - NO_LIBTRACEEVENT=1 \ NO_SHELLCHECK=1 # We need to pass an argument to ld for setting the emulation when
@@ -128,6 +127,12 @@ PERF_MAKE_FLAGS += CORESIGHT=1 # bare "ifdef CORESIGHT" constructs. endif +ifeq ($(BR2_PACKAGE_LIBTRACEEVENT),y) +PERF_DEPENDENCIES += libtraceevent +else +PERF_MAKE_FLAGS += NO_LIBTRACEEVENT=1 +endif + # We really do not want to build the perf documentation, because it # has stringent requirement on the documentation generation tools, # like xmlto and asciidoc), which may be lagging behind on some
Signature · 6 lines
2.50.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 1/2] package/linux-tools: perf: build with libtraceevent support when it is selected
Quoted 42 lines · On mercoledì 9 luglio 2025 17:04:14 Ora legale dell’Europa centrale Alexis…
When trying to perform a custom uprobe recording on a target with perf built by buildroot, the recording step fails as perf can not record uprobes without libtraceevent support:
$ perf probe -x linked_list insert_name index Target program is compiled without optimization. Skipping prologue. Probe on address 0x808 to force probing at the function entry.Added new event:
probe_linked_list:insert_name (oninsert_namein/root/gdb/linked_listwith index)perf is not linked with libtraceevent, to use the new probe you can
use tracefs:cd
/sys/kernel/tracing/
echo 1 > events/probe_linked_list/insert_name/enable echo 1 >tracing_on
cattrace_pipe
Before removing the probe, echo 0 >
events/probe_linked_list/insert_name/enable $ perf record -e probe_linked_list:insert_name ./linked_list event syntax error:
'probe_linked_list:insert_name'
\___ unsupported tracepointlibtraceevent is necessary for tracepoint support Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]-e, --event <event> event selector. use 'perf list' to list
available eventslibtraceevent support for perf has been disabled with commit
b4ab45a5c1db("package/linux-tools: disable libtracevent detection") because there was no libtraceevent package in buildroot to replace the former libtraceevent removed from the kernel sources. Since then, commit1474f1b34b17("package/libtraceevent: new package") has introduced a libtraceevent package. We can then expose again the possibility to build perf with libtraceevent support.
Quoted 4 lines
Make buildroot perf makefile detect if libtraceevent package has been enabled, and if so, allow to build perf with libtraceevent support.
Signed-off-by Alexis Lothoré <[email protected]>
Luca
Signature · 10 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 1/2] package/linux-tools: perf: build with libtraceevent support when it is selected
In reply to Alexis Lothoré via buildrootQuoted 42 lines · Alexis Lothoré via buildroot
When trying to perform a custom uprobe recording on a target with perf built by buildroot, the recording step fails as perf can not record uprobes without libtraceevent support:
$ perf probe -x linked_list insert_name index Target program is compiled without optimization. Skipping prologue. Probe on address 0x808 to force probing at the function entry.Added new event:
probe_linked_list:insert_name (oninsert_namein/root/gdb/linked_listwith index)perf is not linked with libtraceevent, to use the new probe you can
use tracefs:cd
/sys/kernel/tracing/
echo 1 > events/probe_linked_list/insert_name/enable echo 1 >tracing_on
cattrace_pipe
Before removing the probe, echo 0 >
events/probe_linked_list/insert_name/enable$ perf record -e probe_linked_list:insert_name ./linked_list event syntax error: 'probe_linked_list:insert_name' \___ unsupported tracepointlibtraceevent is necessary for tracepoint support Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]-e, --event <event> event selector. use 'perf list' to list
available eventslibtraceevent support for perf has been disabled with commit
b4ab45a5c1db("package/linux-tools: disable libtracevent detection") because there was no libtraceevent package in buildroot to replace the former libtraceevent removed from the kernel sources. Since then, commit1474f1b34b17("package/libtraceevent: new package") has introduced a libtraceevent package. We can then expose again the possibility to build perf with libtraceevent support.
Quoted 4 lines
Make buildroot perf makefile detect if libtraceevent package has been enabled, and if so, allow to build perf with libtraceevent support.
Signed-off-by Alexis Lothoré <[email protected]>
Series applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 1/2] package/linux-tools: perf: build with libtraceevent support when it is selected
In reply to Alexis Lothoré via buildrootIn reply of:
Quoted 38 lines
When trying to perform a custom uprobe recording on a target with perf built by buildroot, the recording step fails as perf can not record uprobes without libtraceevent support:
$ perf probe -x linked_list insert_name index Target program is compiled without optimization. Skipping prologue. Probe on address 0x808 to force probing at the function entry.Added new event:
probe_linked_list:insert_name (oninsert_namein/root/gdb/linked_listwith index)perf is not linked with libtraceevent, to use the new probe you can use tracefs:
cd
/sys/kernel/tracing/
echo 1 > events/probe_linked_list/insert_name/enable
echo 1 >tracing_on
cattrace_pipe
Before removing the probe, echo 0 > events/probe_linked_list/insert_name/enable$ perf record -e probe_linked_list:insert_name ./linked_list event syntax error: 'probe_linked_list:insert_name' \___ unsupported tracepointlibtraceevent is necessary for tracepoint support Run 'perf list' for a list of valid events
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]-e, --event <event> event selector. use 'perf list' to list available events
libtraceevent support for perf has been disabled with commit
b4ab45a5c1db("package/linux-tools: disable libtracevent detection") because there was no libtraceevent package in buildroot to replace the former libtraceevent removed from the kernel sources. Since then, commit1474f1b34b17("package/libtraceevent: new package") has introduced a libtraceevent package. We can then expose again the possibility to build perf with libtraceevent support.
Quoted 4 lines
Make buildroot perf makefile detect if libtraceevent package has been enabled, and if so, allow to build perf with libtraceevent support.
Signed-off-by Alexis Lothoré <[email protected]>
Applied to 2025.02.x and 2025.11.x. Thanks
Quoted 40 lines
---
Changes in v2:
- no change--- package/linux-tools/linux-tool-perf.mk.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)package/linux-tools/linux-tool-perf.mk.in +6
-1@@ -28,7 +28,6 @@ PERF_MAKE_FLAGS = \ NO_LIBPERL=1 \ NO_LIBPYTHON=1 \ NO_LIBBIONIC=1 \ - NO_LIBTRACEEVENT=1 \ NO_SHELLCHECK=1 # We need to pass an argument to ld for setting the emulation when@@ -128,6 +127,12 @@ PERF_MAKE_FLAGS += CORESIGHT=1 # bare "ifdef CORESIGHT" constructs. endif +ifeq ($(BR2_PACKAGE_LIBTRACEEVENT),y) +PERF_DEPENDENCIES += libtraceevent +else +PERF_MAKE_FLAGS += NO_LIBTRACEEVENT=1 +endif + # We really do not want to build the perf documentation, because it # has stringent requirement on the documentation generation tools, # like xmlto and asciidoc), which may be lagging behind on someSignature · 7 lines
-- 2.50.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 2/2 packages/linux-tools: perf: enforce PKG_CONFIG_LIBDIR
In reply to Alexis Lothoré via buildrootFor kernel patched with 440cf77625e3 ("perf: build: Setup PKG_CONFIG_LIBDIR for cross compilation"), if neither PKG_CONFIG_LIBDIR, PKG_CONFIG_PATH nor PKG_CONFIG_SYSROOT_DIR are provided, the perf Makefile while try to set some default value for PKG_CONFIG_LIBDIR, which will not point correctly to buildroot staging directory. This issue will lead for example to a failure to find libtraceevent even if it is correctly enabled and installed in the staging dir, and so it will make perf fail to build.
Make sure to call the perf make command with PKG_CONFIG_LIBDIR variable set and pointing to buildroot staging area to make sure to properly detect perf dependencies.
---
Changes in v2:
- new patch
--- package/linux-tools/linux-tool-perf.mk.in | 1 + 1 file changed, 1 insertion(+)
package/linux-tools/linux-tool-perf.mk.in +1 -0
@@ -23,6 +23,7 @@ PERF_MAKE_FLAGS = \ JOBS=$(PARALLEL_JOBS) \ ARCH=$(PERF_ARCH) \ DESTDIR=$(TARGET_DIR) \ + PKG_CONFIG_LIBDIR="$(STAGING_DIR)/usr/lib/pkgconfig" \ prefix=/usr \ NO_GTK2=1 \ NO_LIBPERL=1 \
Signature · 6 lines
2.50.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 2/2] packages/linux-tools: perf: enforce PKG_CONFIG_LIBDIR
Quoted 9 lines · On mercoledì 9 luglio 2025 17:04:15 Ora legale dell’Europa centrale Alexis…
For kernel patched with
440cf77625e3("perf: build: SetupPKG_CONFIG_LIBDIRfor cross compilation"), if neitherPKG_CONFIG_LIBDIR,PKG_CONFIG_PATHnorPKG_CONFIG_SYSROOT_DIRare provided, the perfMakefilewhile try to set some default value forPKG_CONFIG_LIBDIR, which will not point correctly to buildroot staging directory. This issue will lead for example to a failure to find libtraceevent even if it is correctly enabled and installed in the staging dir, and so it will make perf fail to build.
Quoted 5 lines
Make sure to call the perf make command with
PKG_CONFIG_LIBDIRvariable set and pointing to buildroot staging area to make sure to properly detect perf dependencies.Signed-off-by Alexis Lothoré <[email protected]>
Luca
Signature · 10 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 2/2] packages/linux-tools: perf: enforce PKG_CONFIG_LIBDIR
In reply to Alexis Lothoré via buildrootIn reply of:
Quoted 9 lines
For kernel patched with
440cf77625e3("perf: build: SetupPKG_CONFIG_LIBDIRfor cross compilation"), if neitherPKG_CONFIG_LIBDIR,PKG_CONFIG_PATHnorPKG_CONFIG_SYSROOT_DIRare provided, the perfMakefilewhile try to set some default value forPKG_CONFIG_LIBDIR, which will not point correctly to buildroot staging directory. This issue will lead for example to a failure to find libtraceevent even if it is correctly enabled and installed in the staging dir, and so it will make perf fail to build.
Quoted 5 lines
Make sure to call the perf make command with
PKG_CONFIG_LIBDIRvariable set and pointing to buildroot staging area to make sure to properly detect perf dependencies.Signed-off-by Alexis Lothoré <[email protected]>
Applied to 2025.02.x and 2025.11.x. Thanks
Quoted 27 lines
---
Changes in v2:
- new patch--- package/linux-tools/linux-tool-perf.mk.in | 1 + 1 file changed, 1 insertion(+)package/linux-tools/linux-tool-perf.mk.in +1
-0@@ -23,6 +23,7 @@ PERF_MAKE_FLAGS = \ JOBS=$(PARALLEL_JOBS) \ ARCH=$(PERF_ARCH) \ DESTDIR=$(TARGET_DIR) \ + PKG_CONFIG_LIBDIR="$(STAGING_DIR)/usr/lib/pkgconfig" \ prefix=/usr \ NO_GTK2=1 \ NO_LIBPERL=1 \Signature · 7 lines
-- 2.50.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot