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

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

Ian pointed out that the libcap feature test is also used by bpftool, so
we can't remove it just because perf stopped using it, revert the
removal of the feature test.

Since both perf and libcap uses the fast path feature detection
(tools/build/feature/test-all.c), probably the best thing is to keep
libcap-devel when building perf even it not being used there.

This reverts commit 47b3b6435e4bfb61ae8ffc63a11bd3c310f69acf.

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>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+25 -1
+5 -1
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 \ 28 29 test-libelf.bin \ 29 30 test-libelf-getphdrnum.bin \ 30 31 test-libelf-gelf_getnote.bin \ ··· 112 111 __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS) 113 112 BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1 114 113 BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl 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 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 116 115 117 116 __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS) 118 117 BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1 ··· 139 138 140 139 $(OUTPUT)test-bionic.bin: 141 140 $(BUILD) 141 + 142 + $(OUTPUT)test-libcap.bin: 143 + $(BUILD) -lcap 142 144 143 145 $(OUTPUT)test-libelf.bin: 144 146 $(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 + }