Skip to content

Commit b9c9ce4

Browse files
Sam Luntacmel
authored andcommitted
perf tools: Support Python 3.8+ in Makefile
Python 3.8 changed the output of 'python-config --ldflags' to no longer include the '-lpythonX.Y' flag (this apparently fixed an issue loading modules with a statically linked Python executable). The libpython feature check in linux/build/feature fails if the Python library is not included in FEATURE_CHECK_LDFLAGS-libpython variable. This adds a check in the Makefile to determine if PYTHON_CONFIG accepts the '--embed' flag and passes that flag alongside '--ldflags' if so. tools/perf is the only place the libpython feature check is used. Signed-off-by: Sam Lunt <[email protected]> Tested-by: He Zhe <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Acked-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Cc: [email protected] Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 27486a8 commit b9c9ce4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/perf/Makefile.config

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,17 @@ strip-libs = $(filter-out -l%,$(1))
228228

229229
PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
230230

231+
# Python 3.8 changed the output of `python-config --ldflags` to not include the
232+
# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
233+
# libpython fails if that flag is not included in LDFLAGS
234+
ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
235+
PYTHON_CONFIG_LDFLAGS := --ldflags --embed
236+
else
237+
PYTHON_CONFIG_LDFLAGS := --ldflags
238+
endif
239+
231240
ifdef PYTHON_CONFIG
232-
PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
241+
PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
233242
PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
234243
PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
235244
PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)

0 commit comments

Comments
 (0)