[PATCH v2 1/4] perf build: Build the Python extension before pylint consumers

From: Leo Yan

Date: Wed Sep 30 2026 - 09:42:55 EST


Pylint checks for tests and standalone Python scripts can run before the
perf Python extension is available. On a clean parallel build, an import
error can stop make before the extension is built.

Run the script and test pylint checks in separate sub-makes after the
language bindings are built. Keep their rules in the respective Build
files so the perf and perf-test C sub-makes can compile concurrently with
util and the Python extension. An isolated make perf does not need to
build the extension just for these checks.

Fixes: 8a54784e708b ("perf build: Add pylint build tests")
Reported-by: Aishwarya TCV <aishwarya.tcv@xxxxxxx>
Assisted-by: Codex:gpt-6
Signed-off-by: Leo Yan <leo.yan@xxxxxxx>
---
tools/perf/Build | 4 +++-
tools/perf/Makefile.perf | 15 +++++++++++++++
tools/perf/tests/Build | 4 +++-
3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Build b/tools/perf/Build
index 8a0b5592a973384deafc5bb5cc7ed0cc91e0257e..09fd88f5aca54118a9b089e9c20124e23de77517 100644
--- a/tools/perf/Build
+++ b/tools/perf/Build
@@ -102,4 +102,6 @@ $(OUTPUT)%.pylint_log: %
$(call rule_mkdir)
$(Q)$(call echo-cmd,test)$(PYLINT) "$<" > $@ || (cat $@ && rm $@ && false)

-perf-y += $(PYLINT_TEST_LOGS)
+.PHONY: pylint
+pylint: $(addprefix $(OUTPUT),$(PYLINT_TEST_LOGS))
+ @:
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 0102c3468a0b79fb22966d8cbd8fa8525d2ff3ae..0eb4e7c29c400021907d3da716bc4871f0df8d88 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -578,6 +578,7 @@ strip: $(PROGRAMS) $(OUTPUT)perf
$(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf

PERF_IN := $(OUTPUT)perf-in.o
+
export NO_JEVENTS

build := -f $(srctree)/tools/build/Makefile.build dir=. obj
@@ -633,6 +634,20 @@ $(SCRIPTS) : $(OUTPUT)% : %.sh
$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
$(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)

+ifdef PYLINT
+# Run Python checks after the extension is ready, independently of C builds.
+all: pylint-perf pylint-tests
+.PHONY: pylint-perf pylint-tests
+
+pylint-perf pylint-tests: | $(LANG_BINDINGS)
+
+pylint-perf:
+ $(Q)$(MAKE) $(build)=perf pylint
+
+pylint-tests:
+ $(Q)$(MAKE) $(build)=perf-test dir=tests pylint
+endif
+
# These can record PERF_VERSION
perf.spec $(SCRIPTS) \
: $(OUTPUT)PERF-VERSION-FILE
diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index 8fecd539012429c0f517d95f145a91137333322b..05c545aac73232a322652a6119c3178f39b83145 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -119,4 +119,6 @@ $(OUTPUT)%.pylint_log: %
$(call rule_mkdir)
$(Q)$(call echo-cmd,test)$(PYLINT) "$<" > $@ || (cat $@ && rm $@ && false)

-perf-test-y += $(PYLINT_TEST_LOGS)
+.PHONY: pylint
+pylint: $(addprefix $(OUTPUT)tests/,$(PYLINT_TEST_LOGS))
+ @:

--
2.34.1