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

tools build: Pass libbpf feature only if libbpf 1.0+

libbpf 1.0 represented a cleanup and stabilization of APIs. Simplify
development by only passing the feature test if libbpf 1.0 is installed.

Committer notes:

Change 'make -C tools/perf build-test' so that the LIBBPF_DYNAMIC=1 test
runs only if libbpf is >= 1.0.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Christy Lee <christylee@fb.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quentin Monnet <quentin@isovalent.com>
Cc: Roberto Sassu <roberto.sassu@huawei.com>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20230116010115.490713-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
56d52294 17535a33

+10 -1
+4
tools/build/feature/test-libbpf.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <bpf/libbpf.h> 3 3 4 + #if !defined(LIBBPF_MAJOR_VERSION) || (LIBBPF_MAJOR_VERSION < 1) 5 + #error At least libbpf 1.0 is required for Linux tools. 6 + #endif 7 + 4 8 int main(void) 5 9 { 6 10 return bpf_object__open("test") ? 0 : -1;
+6 -1
tools/perf/tests/make
··· 150 150 run += make_no_libbionic 151 151 run += make_no_auxtrace 152 152 run += make_no_libbpf 153 - run += make_libbpf_dynamic 154 153 run += make_no_libbpf_DEBUG 155 154 run += make_no_libcrypto 156 155 run += make_no_sdt ··· 174 175 # run += make_install_info 175 176 # run += make_install_pdf 176 177 run += make_minimal 178 + 179 + old_libbpf := $(shell echo "#include <bpf/libbpf.h>" | $(CC) -E -dM -x c -| egrep -q "define[[:space:]]+LIBBPF_MAJOR_VERSION[[:space:]]+0{1}") 180 + 181 + ifneq ($(old_libbpf),) 182 + run += make_libbpf_dynamic 183 + endif 177 184 178 185 ifneq ($(call has,ctags),) 179 186 run += make_tags