diff mbox series

perf: fix buildpaths QA warning

Message ID 20230310041237.3384266-1-bruce.ashfield@gmail.com
State Accepted, archived
Commit c8845ab59cd7c28874473618f134a5d45906d6ea
Headers show
Series perf: fix buildpaths QA warning | expand

Commit Message

Bruce Ashfield March 10, 2023, 4:12 a.m. UTC
From: Bruce Ashfield <bruce.ashfield@gmail.com>

In the 6.2+ kernel, arm64 perf has a buildpaths QA warning as
a syscall table is now being dynamically generated. That generated
table includes unistd.h by absolute path, which in turn triggers
the buildpaths QA warning.

This could easily be patched in linux-yocto, but that would
leave the QA issue in perf built from other kernel trees.

So we instead to the following:

 - Add the perf tools directory to the include path
 - Modify the Makefile to have a relative path to unistd.h and
   pass both the relative and absolute path to the generation
   script
 - Modify the generation script to take the relative location
   of unistd.h as a new parameter, and use that in the generated
   sycalls.c file

At build, the added include path of the perf source allows the
relative path file to be included, and no buildpaths warning is
generated.

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---

Ross reported that the ARM CI was showing a buildpaths issue
with perf and the -dev kernel.

I was able to reproduce the issue with qemuarm64, and came up
with this fix.

This was build tested against 6.2, 6.1 and 5.15 kernels, no
issues were found.

Bruce

 meta/recipes-kernel/perf/perf.bb | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/recipes-kernel/perf/perf.bb b/meta/recipes-kernel/perf/perf.bb
index 2f28d16fba..e41fcc4798 100644
--- a/meta/recipes-kernel/perf/perf.bb
+++ b/meta/recipes-kernel/perf/perf.bb
@@ -81,7 +81,7 @@  EXTRA_OEMAKE = '\
     LDSHARED="${CC} -shared" \
     AR="${AR}" \
     LD="${LD}" \
-    EXTRA_CFLAGS="-ldw" \
+    EXTRA_CFLAGS="-ldw -I${S}" \
     YFLAGS='-y --file-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}' \
     EXTRA_LDFLAGS="${PERF_EXTRA_LDFLAGS}" \
     perfexecdir=${libexecdir} \
@@ -280,6 +280,16 @@  do_configure:prepend () {
         sed -i -e "s#os.scandir(path)#sorted(os.scandir(path), key=lambda e: e.name)#g" \
                        "${S}/tools/perf/pmu-events/jevents.py"
     fi
+    if [ -e "${S}/tools/perf/arch/arm64/Makefile" ]; then
+	sed -i 's,sysdef := $(srctree)/,sysdef := ,' ${S}/tools/perf/arch/arm64/Makefile
+	sed -i 's,$(incpath) $(sysdef),$(incpath) $(srctree)/$(sysdef) $(sysdef),' ${S}/tools/perf/arch/arm64/Makefile
+    fi
+    if [ -e "${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl" ]; then
+	if ! grep -q input_rel ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl; then
+	    sed -i 's,input=$4,input=$4\ninput_rel=$5,' ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
+	fi
+	sed -i 's,#include \\"\$input\\",#include \\"\$input_rel\\",'  ${S}/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
+    fi
     # end reproducibility substitutions
 
     # We need to ensure the --sysroot option in CC is preserved