Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools build: Remove needless libpython-version feature check that breaks test-all fast path

Since 66dfdff03d196e51 ("perf tools: Add Python 3 support") we don't use
the tools/build/feature/test-libpython-version.c version in any Makefile
feature check:

$ find tools/ -type f | xargs grep feature-libpython-version
$

The only place where this was used was removed in 66dfdff03d196e51:

- ifneq ($(feature-libpython-version), 1)
- $(warning Python 3 is not yet supported; please set)
- $(warning PYTHON and/or PYTHON_CONFIG appropriately.)
- $(warning If you also have Python 2 installed, then)
- $(warning try something like:)
- $(warning $(and ,))
- $(warning $(and ,) make PYTHON=python2)
- $(warning $(and ,))
- $(warning Otherwise, disable Python support entirely:)
- $(warning $(and ,))
- $(warning $(and ,) make NO_LIBPYTHON=1)
- $(warning $(and ,))
- $(error $(and ,))
- else
- LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
- EXTLIBS += $(PYTHON_EMBED_LIBADD)
- LANG_BINDINGS += $(obj-perf)python/perf.so
- $(call detected,CONFIG_LIBPYTHON)
- endif

And nowadays we either build with PYTHON=python3 or just install the
python3 devel packages and perf will build against it.

But the leftover feature-libpython-version check made the fast path
feature detection to break in all cases except when python2 devel files
were installed:

$ rpm -qa | grep python.*devel
python3-devel-3.9.7-1.fc34.x86_64
$ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ;
$ make -C tools/perf O=/tmp/build/perf install-bin
make: Entering directory '/var/home/acme/git/perf/tools/perf'
BUILD: Doing 'make -j32' parallel build
HOSTCC /tmp/build/perf/fixdep.o
<SNIP>
$ cat /tmp/build/perf/feature/test-all.make.output
In file included from test-all.c:18:
test-libpython-version.c:5:10: error: #error
5 | #error
| ^~~~~
$ ldd ~/bin/perf | grep python
libpython3.9.so.1.0 => /lib64/libpython3.9.so.1.0 (0x00007fda6dbcf000)
$

As python3 is the norm these days, fix this by just removing the unused
feature-libpython-version feature check, making the test-all fast path
to work with the common case.

With this:

$ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ;
$ make -C tools/perf O=/tmp/build/perf install-bin |& head
make: Entering directory '/var/home/acme/git/perf/tools/perf'
BUILD: Doing 'make -j32' parallel build
HOSTCC /tmp/build/perf/fixdep.o
HOSTLD /tmp/build/perf/fixdep-in.o
LINK /tmp/build/perf/fixdep

Auto-detecting system features:
... dwarf: [ on ]
... dwarf_getlocations: [ on ]
... glibc: [ on ]
$ ldd ~/bin/perf | grep python
libpython3.9.so.1.0 => /lib64/libpython3.9.so.1.0 (0x00007f58800b0000)
$ cat /tmp/build/perf/feature/test-all.make.output
$

Reviewed-by: James Clark <james.clark@arm.com>
Fixes: 66dfdff03d196e51 ("perf tools: Add Python 3 support")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jaroslav Škarvada <jskarvad@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/YaYmeeC6CS2b8OSz@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

-23
-1
tools/build/Makefile.feature
··· 48 48 numa_num_possible_cpus \ 49 49 libperl \ 50 50 libpython \ 51 - libpython-version \ 52 51 libslang \ 53 52 libslang-include-subdir \ 54 53 libtraceevent \
-4
tools/build/feature/Makefile
··· 32 32 test-numa_num_possible_cpus.bin \ 33 33 test-libperl.bin \ 34 34 test-libpython.bin \ 35 - test-libpython-version.bin \ 36 35 test-libslang.bin \ 37 36 test-libslang-include-subdir.bin \ 38 37 test-libtraceevent.bin \ ··· 225 226 226 227 $(OUTPUT)test-libpython.bin: 227 228 $(BUILD) $(FLAGS_PYTHON_EMBED) 228 - 229 - $(OUTPUT)test-libpython-version.bin: 230 - $(BUILD) 231 229 232 230 $(OUTPUT)test-libbfd.bin: 233 231 $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
-5
tools/build/feature/test-all.c
··· 14 14 # include "test-libpython.c" 15 15 #undef main 16 16 17 - #define main main_test_libpython_version 18 - # include "test-libpython-version.c" 19 - #undef main 20 - 21 17 #define main main_test_libperl 22 18 # include "test-libperl.c" 23 19 #undef main ··· 173 177 int main(int argc, char *argv[]) 174 178 { 175 179 main_test_libpython(); 176 - main_test_libpython_version(); 177 180 main_test_libperl(); 178 181 main_test_hello(); 179 182 main_test_libelf();
-11
tools/build/feature/test-libpython-version.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - #include <Python.h> 3 - 4 - #if PY_VERSION_HEX >= 0x03000000 5 - #error 6 - #endif 7 - 8 - int main(void) 9 - { 10 - return 0; 11 - }
-2
tools/perf/Makefile.config
··· 271 271 272 272 FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS) 273 273 FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS) 274 - FEATURE_CHECK_CFLAGS-libpython-version := $(PYTHON_EMBED_CCOPTS) 275 - FEATURE_CHECK_LDFLAGS-libpython-version := $(PYTHON_EMBED_LDOPTS) 276 274 277 275 FEATURE_CHECK_LDFLAGS-libaio = -lrt 278 276