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

tools build: Remove leftover libcap tests that prevents fast path feature detection from working

I noticed that the fast path feature detection was failing:

$ cat /tmp/build/perf-tools-next/feature/test-all.make.output
/usr/bin/ld: cannot find -lcap: No such file or directory
collect2: error: ld returned 1 exit status
$

The patch removing the dependency (Fixes tag below) didn't remove the
detection of libcap, and as the fast path feature detection (test-all.c)
had -lcap in its Makefile link list of libraries to link, it was failing
when libcap-devel is not available, fix it by removing those leftover
files.

Fixes: e25ebda78e230283 ("perf cap: Tidy up and improve capability testing")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/Zs-gjOGFWtAvIZit@x1
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+1 -25
+1 -5
tools/build/feature/Makefile
··· 25 25 test-libbfd-liberty-z.bin \ 26 26 test-cplus-demangle.bin \ 27 27 test-cxa-demangle.bin \ 28 - test-libcap.bin \ 29 28 test-libelf.bin \ 30 29 test-libelf-getphdrnum.bin \ 31 30 test-libelf-gelf_getnote.bin \ ··· 111 112 __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS) 112 113 BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1 113 114 BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl 114 - BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma -lzstd -lcap 115 + BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma -lzstd 115 116 116 117 __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS) 117 118 BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1 ··· 138 139 139 140 $(OUTPUT)test-bionic.bin: 140 141 $(BUILD) 141 - 142 - $(OUTPUT)test-libcap.bin: 143 - $(BUILD) -lcap 144 142 145 143 $(OUTPUT)test-libelf.bin: 146 144 $(BUILD) -lelf
-20
tools/build/feature/test-libcap.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - #include <sys/capability.h> 3 - #include <linux/capability.h> 4 - 5 - int main(void) 6 - { 7 - cap_flag_value_t val; 8 - cap_t caps = cap_get_proc(); 9 - 10 - if (!caps) 11 - return 1; 12 - 13 - if (cap_get_flag(caps, CAP_SYS_ADMIN, CAP_EFFECTIVE, &val) != 0) 14 - return 1; 15 - 16 - if (cap_free(caps) != 0) 17 - return 1; 18 - 19 - return 0; 20 - }