Skip to contentSkip to conversation

perf tools: Fix make PYTHON override

PATCH In review Namhyung Kim 4 participants 10 messages Jul 29, 2014 – Aug 13, 2014 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH v2 1/2 perf tools: Fix make PYTHON override

Thomas reported that make PYTHON=python2 is not work on some systems. I can reproduce it on my ArchLinux box too.

This is because it's overridden by config/feature-checks/Makefile regardless of PYTHON setting. I guess it's a bug slipped into during the feature checking change.

Actually, we don't need to check python-config in the feature-checks. We can just pass appropriate FEATURE_CHECK_*FLAGS.

---
 tools/perf/config/Makefile                | 34 ++++++++++++++++++++-----------
 tools/perf/config/feature-checks/Makefile | 18 ++--------------
 2 files changed, 24 insertions(+), 28 deletions(-)
tools/perf/config/Makefile +22 -12
index 1f67aa02d240..e05d8f99424d 100644
@@ -120,6 +120,23 @@ ifdef PARSER_DEBUG
   CFLAGS             += -DPARSER_DEBUG
 endif
 
+ifndef NO_LIBPYTHON
+  override PYTHON := \
+    $(call get-executable-or-default,PYTHON,python)
+  override PYTHON_CONFIG := \
+    $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+
+  PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
+
+  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
+  PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
+
+  FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
+  FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
+  FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
+  FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
+endif
+
 CFLAGS += -fno-omit-frame-pointer
 CFLAGS += -ggdb3
 CFLAGS += -funwind-tables
@@ -482,21 +499,14 @@ define disable-python_code
   NO_LIBPYTHON := 1
 endef
 
-override PYTHON := \
-  $(call get-executable-or-default,PYTHON,python)
-
-ifndef PYTHON
-  $(call disable-python,python interpreter)
+ifdef NO_LIBPYTHON
+  $(call disable-python)
 else
 
-  PYTHON_WORD := $(call shell-wordify,$(PYTHON))
-
-  ifdef NO_LIBPYTHON
-    $(call disable-python)
+  ifndef PYTHON
+    $(call disable-python,python interpreter)
   else
-
-    override PYTHON_CONFIG := \
-      $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+    PYTHON_WORD := $(call shell-wordify,$(PYTHON))
 
     ifndef PYTHON_CONFIG
       $(call disable-python,python-config tool)
tools/perf/config/feature-checks/Makefile +2 -16
index 6088f8d8a434..72ab2984718e 100644
@@ -101,25 +101,11 @@ FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
 test-libperl.bin:
 	$(BUILD) $(FLAGS_PERL_EMBED)
 
-override PYTHON := python
-override PYTHON_CONFIG := python-config
-
-escape-for-shell-sq =  $(subst ','\'',$(1))
-shell-sq = '$(escape-for-shell-sq)'
-
-PYTHON_CONFIG_SQ = $(call shell-sq,$(PYTHON_CONFIG))
-
-PYTHON_EMBED_LDOPTS = $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
-PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
-PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
-PYTHON_EMBED_CCOPTS = $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
-FLAGS_PYTHON_EMBED = $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
-
 test-libpython.bin:
-	$(BUILD) $(FLAGS_PYTHON_EMBED)
+	$(BUILD)
 
 test-libpython-version.bin:
-	$(BUILD) $(FLAGS_PYTHON_EMBED)
+	$(BUILD)
 
 test-libbfd.bin:
 	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
Signature · 1 line
2.0.0
author maintainer
#1 lore raw

PATCH v2 2/2 perf tools: Default to python version 2

According to PEP 394 recommendation [1], it's more portable to use python2 rather than plain python to refer python binary version 2.

Since there're distros using python3 by default like Arch, and we don't support python3 (yet), it'd be better using python2 explicitly.

But older versions (prior to 2.7) seem not to provide python2 but just python. Given that it's only old version, try python2 first and then fallback to python. It'll ensure that it always points to python 2.x.

[1] https://www.python.org/dev/peps/pep-0394

---
 tools/perf/config/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +2 -2
index e05d8f99424d..60177278a357 100644
@@ -121,8 +121,8 @@ ifdef PARSER_DEBUG
 endif
 
 ifndef NO_LIBPYTHON
-  override PYTHON := \
-    $(call get-executable-or-default,PYTHON,python)
+  PYTHON2 := $(if $(call get-executable,python2),python2,python)
+  override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
   override PYTHON_CONFIG := \
     $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
 
Signature · 1 line
2.0.0
#2 lore raw

Re: [PATCH v2 2/2] perf tools: Default to python version 2

Em Tue, Jul 29, 2014 at 03:57:20PM +0900, Namhyung Kim escreveu:

Quoted 9 lines

According to PEP 394 recommendation [1], it's more portable to use python2 rather than plain python to refer python binary version 2.

Since there're distros using python3 by default like Arch, and we don't support python3 (yet), it'd be better using python2 explicitly.

But older versions (prior to 2.7) seem not to provide python2 but just python. Given that it's only old version, try python2 first and then fallback to python. It'll ensure that it always points to python 2.x.

It should fallback, right?

[acme@fedora14 linux]$ ls -la /usr/bin/python2-config
ls: cannot access /usr/bin/python2-config: No such file or directory [acme@fedora14 linux]$ ls -la /usr/bin/python-config
lrwxrwxrwx. 1 root root 16 Mar 25 09:43 /usr/bin/python-config -> python2.7-config [acme@fedora14 linux]$ rpm -qf /usr/bin/python-config python-devel-2.7-8.fc14.1.x86_64
[acme@fedora14 linux]$ cat /etc/fedora-release
Fedora release 14 (Laughlin)
[acme@fedora14 linux]$

[acme@fedora14 linux]$ time make O=/tmp/build/perf -C tools/perf install
make: Entering directory `/home/acme/git/linux/tools/perf'
BUILD: Doing 'make -j4' parallel build
config/Makefile:126: The path '/usr/bin/python2-config' is not executable. config/Makefile:339: No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR config/Makefile:481: Missing perl devel files. Disabling perl scripting support, consider installing perl-ExtUtils-Embed config/Makefile:512: No python-config tool was found config/Makefile:512: Python support will not be built

Quoted 26 lines

[1] https://www.python.org/dev/peps/pep-0394

---
 tools/perf/config/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +2 -2
index e05d8f99424d..60177278a357 100644
@@ -121,8 +121,8 @@ ifdef PARSER_DEBUG
 endif
 
 ifndef NO_LIBPYTHON
-  override PYTHON := \
-    $(call get-executable-or-default,PYTHON,python)
+  PYTHON2 := $(if $(call get-executable,python2),python2,python)
+  override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
   override PYTHON_CONFIG := \
     $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
 
Signature · 1 line
2.0.0
#3 lore raw

Re: [PATCH v2 2/2] perf tools: Default to python version 2

Zitat von Arnaldo Carvalho de Melo <[email protected]>:

Quoted 4 lines

Em Tue, Jul 29, 2014 at 03:57:20PM +0900, Namhyung Kim escreveu:

Quoted 3 lines

According to PEP 394 recommendation [1], it's more portable to use python2 rather than plain python to refer python binary version 2.

Quoted 8 lines
Quoted 6 lines

Since there're distros using python3 by default like Arch, and we don't support python3 (yet), it'd be better using python2 explicitly.

But older versions (prior to 2.7) seem not to provide python2 but just python. Given that it's only old version, try python2 first and then fallback to python. It'll ensure that it always points to python 2.x.

It should fallback, right?

Yes.

Quoted 5 lines

[acme@fedora14 linux]$ ls -la /usr/bin/python2-config
ls: cannot access /usr/bin/python2-config: No such file or directory [acme@fedora14 linux]$ ls -la /usr/bin/python-config lrwxrwxrwx. 1 root root 16 Mar 25 09:43 /usr/bin/python-config -> python2.7-config

Appearently this fedora package symlinks python -> python2 but does not so for python2-config. The Makefile looks for either python2 or python as fallback and then assumes that a respective "-config" exists. I think this is a sane assumption.

I guess if this needs to be supported, there needs to be another fallback if $(PYTHON)-config is not found to try python-config again. However this may behave weirdly if someone has python2, no python2-devel but python3-devel installed, sets PYTHON=python2 and then still gets a version error. Or we somehow only fallback if no PYTHON is specified (not sure how to implemented that elegantly).

Best,
Thomas

Quoted 43 lines

[acme@fedora14 linux]$ rpm -qf /usr/bin/python-config python-devel-2.7-8.fc14.1.x86_64 [acme@fedora14 linux]$ cat /etc/fedora-release Fedora release 14 (Laughlin)
[acme@fedora14 linux]$

[acme@fedora14 linux]$ time make O=/tmp/build/perf -C tools/perf install
make: Entering directory `/home/acme/git/linux/tools/perf'
BUILD: Doing 'make -j4' parallel build
config/Makefile:126: The path '/usr/bin/python2-config' is not executable. config/Makefile:339: No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR config/Makefile:481: Missing perl devel files. Disabling perl scripting support, consider installing perl-ExtUtils-Embed config/Makefile:512: No python-config tool was found config/Makefile:512: Python support will not be built

Quoted 26 lines

[1] https://www.python.org/dev/peps/pep-0394

---
 tools/perf/config/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +2 -3
index e05d8f99424d..60177278a357 100644
@@ -121,8 +121,8 @@ ifdef PARSER_DEBUG
 endif
 
 ifndef NO_LIBPYTHON
-  override PYTHON := \
-    $(call get-executable-or-default,PYTHON,python)
+  PYTHON2 := $(if $(call get-executable,python2),python2,python)
+  override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
   override PYTHON_CONFIG := \
     $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
 
--

2.0.0

#4 lore raw

Re: [PATCH v2 2/2] perf tools: Default to python version 2

Em Sat, Aug 02, 2014 at 12:56:48PM +0200, Thomas Ilsche escreveu:

Quoted 24 lines

Zitat von Arnaldo Carvalho de Melo <[email protected]>:

Quoted 4 lines

Em Tue, Jul 29, 2014 at 03:57:20PM +0900, Namhyung Kim escreveu:

Quoted 3 lines

According to PEP 394 recommendation [1], it's more portable to use python2 rather than plain python to refer python binary version 2.

Quoted 8 lines
Quoted 6 lines

Since there're distros using python3 by default like Arch, and we don't support python3 (yet), it'd be better using python2 explicitly.

But older versions (prior to 2.7) seem not to provide python2 but just python. Given that it's only old version, try python2 first and then fallback to python. It'll ensure that it always points to python 2.x.

It should fallback, right?

Yes.

Quoted 5 lines

[acme@fedora14 linux]$ ls -la /usr/bin/python2-config
ls: cannot access /usr/bin/python2-config: No such file or directory [acme@fedora14 linux]$ ls -la /usr/bin/python-config lrwxrwxrwx. 1 root root 16 Mar 25 09:43 /usr/bin/python-config -> python2.7-config

Quoted 3 lines

Appearently this fedora package symlinks python -> python2 but does not so for python2-config. The Makefile looks for either python2 or python as fallback and then assumes that a respective "-config" exists. I think this is a sane assumption.

Maybe the way python was packaged on f14 is problematic, as you describe, but the fact is that python support is not working on that platform after this patch.

Could you please try to prepare a patch that does as you suggest so that I can try?

Thanks,

- Arnaldo

Quoted 58 lines

I guess if this needs to be supported, there needs to be another fallback if $(PYTHON)-config is not found to try python-config again. However this may behave weirdly if someone has python2, no python2-devel but python3-devel installed, sets PYTHON=python2 and then still gets a version error. Or we somehow only fallback if no PYTHON is specified (not sure how to implemented that elegantly).

Best,
Thomas

Quoted 43 lines

[acme@fedora14 linux]$ rpm -qf /usr/bin/python-config python-devel-2.7-8.fc14.1.x86_64 [acme@fedora14 linux]$ cat /etc/fedora-release Fedora release 14 (Laughlin)
[acme@fedora14 linux]$

[acme@fedora14 linux]$ time make O=/tmp/build/perf -C tools/perf install
make: Entering directory `/home/acme/git/linux/tools/perf'
BUILD: Doing 'make -j4' parallel build
config/Makefile:126: The path '/usr/bin/python2-config' is not executable. config/Makefile:339: No libdw DWARF unwind found, Please install elfutils-devel/libdw-dev >= 0.158 and/or set LIBDW_DIR config/Makefile:481: Missing perl devel files. Disabling perl scripting support, consider installing perl-ExtUtils-Embed config/Makefile:512: No python-config tool was found config/Makefile:512: Python support will not be built

Quoted 26 lines

[1] https://www.python.org/dev/peps/pep-0394

---
 tools/perf/config/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/config/Makefile +2 -3
index e05d8f99424d..60177278a357 100644
@@ -121,8 +121,8 @@ ifdef PARSER_DEBUG
 endif
 
 ifndef NO_LIBPYTHON
-  override PYTHON := \
-    $(call get-executable-or-default,PYTHON,python)
+  PYTHON2 := $(if $(call get-executable,python2),python2,python)
+  override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
   override PYTHON_CONFIG := \
     $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
 
--

2.0.0

#5 lore raw

PATCH v3 2/2 perf tools: Default to python version 2

Quoted 6 lines · Arnaldo Carvalho de Melo

Maybe the way python was packaged on f14 is problematic, as you describe, but the fact is that python support is not working on that platform after this patch.

Could you please try to prepare a patch that does as you suggest so that I can try?

Please try the patch below.
I tested (compiles and perf script runs) with the combinations:

1) python -> python2.x, python-config -> python2.x-config
python2 N/A, python2-config N/A

2) python -> python3.x, python-config -> python3.x-config python2 -> python2.x, python2-config -> python2.x-config

3) python -> python2.x, python-config -> python2.x-config python2 -> python2.x, python2-config -> python2.x-config

4) python -> python2.x, python-config -> python2.x-config python2 -> python2.x, python2-config N/A

Based on / replaces the patch 2/2 by Namhyung Kim.

---

tools/perf/config/Makefile +9 -3
index 9ee2008..0528cd37 100644
@@ -104,10 +104,16 @@ ifdef PARSER_DEBUG
 endif
 
 ifndef NO_LIBPYTHON
-  override PYTHON := \
-    $(call get-executable-or-default,PYTHON,python)
+  # Try different combinations to accommodate systems that only have
+  # python[2][-config] in weird combinations but always preferring
+  # python2 and python2-config as per pep-0394. If we catch a
+  # python[-config] in version 3, the version check will kill it.
+  PYTHON2 := $(if $(call get-executable,python2),python2,python)
+  override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
+  PYTHON2_CONFIG := \
+    $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
   override PYTHON_CONFIG := \
-    $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+    $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
 
   PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
#6 lore raw

Re: [PATCH v3 2/2] perf tools: Default to python version 2

Em Mon, Aug 04, 2014 at 03:03:15PM +0200, Thomas Ilsche escreveu:

Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 6 lines

Maybe the way python was packaged on f14 is problematic, as you describe, but the fact is that python support is not working on that platform after this patch.

Could you please try to prepare a patch that does as you suggest so that I can try?

Please try the patch below.
I tested (compiles and perf script runs) with the combinations:

Thanks, now it works (my perf/core branch + this patch) on:

fedora14 x86_64
fedora19 x86_64
fedora20 x86_64
RHEL6.3 x86_64
opensuse12.3 i386
ubuntu13.10 x86_64

- Arnaldo

#7 lore raw

[tip:perf/core] perf tools: Default to python version 2

In reply to Thomas Ilsche
perf tools: Default to python version 2
Commit-ID:  d6a947fb6cdff3a19db93895c746f70b5903a965
Gitweb:     http://git.kernel.org/tip/d6a947fb6cdff3a19db93895c746f70b5903a965
Author:     Thomas Ilsche <[email protected]>
AuthorDate: Mon, 4 Aug 2014 15:03:15 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 12 Aug 2014 12:03:08 -0300

perf tools: Default to python version 2

According to PEP 394 recommendation [1], it's more portable to use python2 rather than plain python to refer python binary version 2.

Since there're distros using python3 by default like Arch, and we don't support python3 (yet), it'd be better using python2 explicitly.

But older versions (prior to 2.7) seem not to provide python2 but just python. Given that it's only old version, try python2 first and then fallback to python. It'll ensure that it always points to python 2.x.

I tested (compiles and perf script runs) with the combinations:

1) python -> python2.x, python-config -> python2.x-config
python2 N/A, python2-config N/A

2) python -> python3.x, python-config -> python3.x-config python2 -> python2.x, python2-config -> python2.x-config

3) python -> python2.x, python-config -> python2.x-config python2 -> python2.x, python2-config -> python2.x-config

4) python -> python2.x, python-config -> python2.x-config python2 -> python2.x, python2-config N/A

Based on / replaces the patch 2/2 by Namhyung Kim.

[1] https://www.python.org/dev/peps/pep-0394

---
 tools/perf/config/Makefile | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
tools/perf/config/Makefile +9 -3
index e05d8f9..75d4c23 100644
@@ -121,10 +121,16 @@ ifdef PARSER_DEBUG
 endif
 
 ifndef NO_LIBPYTHON
-  override PYTHON := \
-    $(call get-executable-or-default,PYTHON,python)
+  # Try different combinations to accommodate systems that only have
+  # python[2][-config] in weird combinations but always preferring
+  # python2 and python2-config as per pep-0394. If we catch a
+  # python[-config] in version 3, the version check will kill it.
+  PYTHON2 := $(if $(call get-executable,python2),python2,python)
+  override PYTHON := $(call get-executable-or-default,PYTHON,$(PYTHON2))
+  PYTHON2_CONFIG := \
+    $(if $(call get-executable,$(PYTHON)-config),$(PYTHON)-config,python-config)
   override PYTHON_CONFIG := \
-    $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+    $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON2_CONFIG))
 
   PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
 
#8 lore raw
In reply to Namhyung Kim

Em Tue, Jul 29, 2014 at 03:57:19PM +0900, Namhyung Kim escreveu:

Quoted 7 lines

Thomas reported that make PYTHON=python2 is not work on some systems. I can reproduce it on my ArchLinux box too.

This is because it's overridden by config/feature-checks/Makefile regardless of PYTHON setting. I guess it's a bug slipped into during the feature checking change.

Quoted 5 lines

Actually, we don't need to check python-config in the feature-checks. We can just pass appropriate FEATURE_CHECK_*FLAGS.

Thanks, both patches applied.

- Arnaldo

#9 lore raw
In reply to Namhyung Kim
perf tools: Fix make PYTHON override
Commit-ID:  56c7d79e49776084b852e451bda5f59dc3bcf894
Gitweb:     http://git.kernel.org/tip/56c7d79e49776084b852e451bda5f59dc3bcf894
Author:     Namhyung Kim <[email protected]>
AuthorDate: Tue, 29 Jul 2014 15:57:19 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 12 Aug 2014 12:03:04 -0300

perf tools: Fix make PYTHON override

Thomas reported that make PYTHON=python2 is not work on some systems. I can reproduce it on my ArchLinux box too.

This is because it's overridden by config/feature-checks/Makefile regardless of PYTHON setting. I guess it's a bug slipped into during the feature checking change.

Actually, we don't need to check python-config in the feature-checks. We can just pass appropriate FEATURE_CHECK_*FLAGS.

---
 tools/perf/config/Makefile                | 34 ++++++++++++++++++++-----------
 tools/perf/config/feature-checks/Makefile | 18 ++--------------
 2 files changed, 24 insertions(+), 28 deletions(-)
tools/perf/config/Makefile +22 -12
index 1f67aa0..e05d8f9 100644
@@ -120,6 +120,23 @@ ifdef PARSER_DEBUG
   CFLAGS             += -DPARSER_DEBUG
 endif
 
+ifndef NO_LIBPYTHON
+  override PYTHON := \
+    $(call get-executable-or-default,PYTHON,python)
+  override PYTHON_CONFIG := \
+    $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+
+  PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
+
+  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
+  PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
+
+  FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
+  FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
+  FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS)
+  FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS)
+endif
+
 CFLAGS += -fno-omit-frame-pointer
 CFLAGS += -ggdb3
 CFLAGS += -funwind-tables
@@ -482,21 +499,14 @@ define disable-python_code
   NO_LIBPYTHON := 1
 endef
 
-override PYTHON := \
-  $(call get-executable-or-default,PYTHON,python)
-
-ifndef PYTHON
-  $(call disable-python,python interpreter)
+ifdef NO_LIBPYTHON
+  $(call disable-python)
 else
 
-  PYTHON_WORD := $(call shell-wordify,$(PYTHON))
-
-  ifdef NO_LIBPYTHON
-    $(call disable-python)
+  ifndef PYTHON
+    $(call disable-python,python interpreter)
   else
-
-    override PYTHON_CONFIG := \
-      $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
+    PYTHON_WORD := $(call shell-wordify,$(PYTHON))
 
     ifndef PYTHON_CONFIG
       $(call disable-python,python-config tool)
tools/perf/config/feature-checks/Makefile +2 -16
index 6088f8d..72ab298 100644
@@ -101,25 +101,11 @@ FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
 test-libperl.bin:
 	$(BUILD) $(FLAGS_PERL_EMBED)
 
-override PYTHON := python
-override PYTHON_CONFIG := python-config
-
-escape-for-shell-sq =  $(subst ','\'',$(1))
-shell-sq = '$(escape-for-shell-sq)'
-
-PYTHON_CONFIG_SQ = $(call shell-sq,$(PYTHON_CONFIG))
-
-PYTHON_EMBED_LDOPTS = $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
-PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
-PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
-PYTHON_EMBED_CCOPTS = $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
-FLAGS_PYTHON_EMBED = $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
-
 test-libpython.bin:
-	$(BUILD) $(FLAGS_PYTHON_EMBED)
+	$(BUILD)
 
 test-libpython-version.bin:
-	$(BUILD) $(FLAGS_PYTHON_EMBED)
+	$(BUILD)
 
 test-libbfd.bin:
 	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl