2022-02-01 22:59 UTC-0800 ~ Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> > On Mon, Jan 31, 2022 at 1:11 PM Quentin Monnet <quentin@xxxxxxxxxxxxx> wrote: >> >> To help users check what version of libbpf has been used to compile >> bpftool, embed the version number and print it along with bpftool's own >> version number. >> >> Signed-off-by: Quentin Monnet <quentin@xxxxxxxxxxxxx> >> --- >> tools/bpf/bpftool/Documentation/common_options.rst | 3 ++- >> tools/bpf/bpftool/Makefile | 2 ++ >> tools/bpf/bpftool/main.c | 3 +++ >> 3 files changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/tools/bpf/bpftool/Documentation/common_options.rst b/tools/bpf/bpftool/Documentation/common_options.rst >> index 908487b9c2ad..24166733d3ae 100644 >> --- a/tools/bpf/bpftool/Documentation/common_options.rst >> +++ b/tools/bpf/bpftool/Documentation/common_options.rst >> @@ -4,7 +4,8 @@ >> Print short help message (similar to **bpftool help**). >> >> -V, --version >> - Print version number (similar to **bpftool version**), and optional >> + Print bpftool's version number (similar to **bpftool version**), the >> + version of libbpf that was used to compile the binary, and optional >> features that were included when bpftool was compiled. Optional >> features include linking against libbfd to provide the disassembler >> for JIT-ted programs (**bpftool prog dump jited**) and usage of BPF >> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile >> index 83369f55df61..bd5a8cafac49 100644 >> --- a/tools/bpf/bpftool/Makefile >> +++ b/tools/bpf/bpftool/Makefile >> @@ -42,6 +42,7 @@ LIBBPF_BOOTSTRAP_INTERNAL_HDRS := $(addprefix $(LIBBPF_BOOTSTRAP_HDRS_DIR)/,hash >> ifeq ($(BPFTOOL_VERSION),) >> BPFTOOL_VERSION := $(shell make -rR --no-print-directory -sC ../../.. kernelversion) >> endif >> +LIBBPF_VERSION := $(shell make -r --no-print-directory -sC $(BPF_DIR) libbpfversion) >> > > why can't you use libbpf_version_string() API instead? I missed it somehow, thanks for the pointer. It seems to be a recent addition to libbpf, and it was probably not present last time I checked for such an API. I'll use it.