From 070cb3e7961210adc6890827a75dbc358dfc9809 Mon Sep 17 00:00:00 2001
From: Peter Jung <ptr1337@archlinux.org>
Date: Fri, 13 Dec 2024 08:17:13 +0100
Subject: [PATCH] linux-tools: Add pfm support

pfm is a helper library used by application to program specific monitoring events.
This is commonly and often used in profiling processes and makes it easier to choose the correct event.

Example:
AutoFDO for the Kernel provides in their instructions following command:
perf record --pfm-events RETIRED_TAKEN_BRANCH_INSTRUCTIONS:k -a -N -b -c 500009 -o kernel.data -- time makepkg -s

This results currently into following:
`Error: unknown option `pfm-events' `

Since this is commonly used in many instructions add support for it, so that its easier for users and developers to use these events.

Signed-off-by: Peter Jung <ptr1337@archlinux.org>
---
 PKGBUILD | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/PKGBUILD b/PKGBUILD
index 84b5c9f..5dee0d9 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -26,7 +26,7 @@ makedepends=('git')
 makedepends+=('asciidoc' 'xmlto')
 # perf deps
 makedepends+=('perl' 'python' 'python-setuptools' 'slang' 'elfutils' 'libunwind'
-  'numactl' 'audit' 'zstd' 'libcap' 'libtraceevent' 'openssl' 'clang' 'llvm-libs')
+  'numactl' 'audit' 'zstd' 'libcap' 'libtraceevent' 'openssl' 'clang' 'llvm-libs' 'libpfm')
 # cpupower deps
 makedepends+=('pciutils')
 # usbip deps
@@ -96,6 +96,7 @@ build() {
     PYTHON=python \
     NO_LIBLLVM=1 \
     PYTHON_CONFIG=python-config \
+    LIBPFM4=1 \
     DESTDIR="$pkgdir"
   popd
 
@@ -177,7 +178,7 @@ package_perf() {
   pkgdesc='Linux kernel performance auditing tool'
   depends=('glibc' 'perl' 'python' 'slang' 'elfutils' 'libunwind' 'binutils'
            'numactl' 'audit' 'coreutils' 'glib2' 'xz' 'zlib' 'libelf' 'bash'
-           'zstd' 'libcap' 'libtraceevent' 'openssl' 'libsframe.so' 'llvm-libs')
+           'zstd' 'libcap' 'libtraceevent' 'openssl' 'libsframe.so' 'llvm-libs' 'libpfm')
 
   cd linux/tools/perf
   make -f Makefile.perf \
@@ -191,6 +192,7 @@ package_perf() {
     NO_LIBLLVM=1 \
     PYTHON_CONFIG=python-config \
     DESTDIR="$pkgdir" \
+    LIBPFM4=1 \
     install install-python_ext
   cd "$pkgdir"
   # add linker search path
-- 
GitLab