Skip to content

Commit caec547

Browse files
captain5050acmel
authored andcommitted
perf build: Fix python/perf.so library's name
Since Python 3.3 extensions have a suffix encoding platform and version information. For example, the perf extension was previously perf.so but now maybe perf.cpython-310-x86_64-linux-gnu.so. Compute the extension using Python and then use this in the target name. Doing this avoids the "perf.so" target always being rebuilt. Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexey Bayduraev <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Anshuman Khandual <[email protected]> Cc: Athira Jajeev <[email protected]> Cc: Eelco Chaudron <[email protected]> Cc: German Gomez <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Kim Phillips <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Riccardo Mancini <[email protected]> Cc: Sandipan Das <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Shaomin Deng <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Timothy Hayes <[email protected]> Cc: Xing Zhengjun <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 9440ebd commit caec547

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

tools/perf/Makefile.config

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ define disable-python_code
871871
NO_LIBPYTHON := 1
872872
endef
873873

874+
PYTHON_EXTENSION_SUFFIX := '.so'
874875
ifdef NO_LIBPYTHON
875876
$(call disable-python,Python support disabled by user)
876877
else
@@ -889,7 +890,8 @@ else
889890
else
890891
LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
891892
EXTLIBS += $(PYTHON_EMBED_LIBADD)
892-
LANG_BINDINGS += $(obj-perf)python/perf.so
893+
PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])')
894+
LANG_BINDINGS += $(obj-perf)python/perf$(PYTHON_EXTENSION_SUFFIX)
893895
CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
894896
$(call detected,CONFIG_LIBPYTHON)
895897
endif

tools/perf/Makefile.perf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
647647
# Create python binding output directory if not already present
648648
_dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')
649649

650-
$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBPERF)
650+
$(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX): $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBPERF)
651651
$(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
652652
CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' \
653653
$(PYTHON_WORD) util/setup.py \

0 commit comments

Comments
 (0)