From 7b65e2034fde011d090d4ec472902b71129c6cbd Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Tue, 26 Nov 2019 13:12:53 +0100 Subject: perf tools: Allow to link with libbpf dynamicaly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently we support only static linking with kernel's libbpf (tools/lib/bpf). This patch adds libbpf package detection and support to link perf with it dynamically. The libbpf package status is displayed with: $ make VF=1 Auto-detecting system features: ... ... libbpf: [ on ] It's not checked by default, because it's quite new. Once it's on most distros we can switch it on. For the same reason it's not added to the test-all check. Perf does not need advanced version of libbpf, so we can check just for the base bpf_object__open function. Adding new compile variable to detect libbpf package and link bpf dynamically: $ make LIBBPF_DYNAMIC=1 ... LINK perf $ ldd perf | grep bpf libbpf.so.0 => /lib64/libbpf.so.0 (0x00007f46818bc000) If libbpf is not installed, build stops with: Makefile.config:486: *** Error: No libbpf devel library found,\ please install libbpf-devel. Stop. Committer testing: $ make LIBBPF_DYNAMIC=1 -C tools/perf O=/tmp/build/perf make: Entering directory '/home/acme/git/perf/tools/perf' BUILD: Doing 'make -j8' parallel build Makefile.config:493: *** Error: No libbpf devel library found, please install libbpf-devel. Stop. make[1]: *** [Makefile.perf:225: sub-make] Error 2 make: *** [Makefile:70: all] Error 2 make: Leaving directory '/home/acme/git/perf/tools/perf' $ Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Cc: Toke Høiland-Jørgensen Cc: Alexander Shishkin Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Daniel Borkmann Cc: Jesper Dangaard Brouer Cc: Martin KaFai Lau Cc: Michael Petlan Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Cc: Yonghong Song Cc: bpf@vger.kernel.org Cc: netdev@vger.kernel.org Link: http://lore.kernel.org/lkml/20191126121253.28253-1-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Makefile.perf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tools/perf/Makefile.perf') diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 1cd294468a1f..eae5d5e95952 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -116,6 +116,8 @@ include ../scripts/utilities.mak # # Define TCMALLOC to enable tcmalloc heap profiling. # +# Define LIBBPF_DYNAMIC to enable libbpf dynamic linking. +# # As per kernel Makefile, avoid funny character set dependencies unexport LC_ALL @@ -360,7 +362,9 @@ export PERL_PATH PERFLIBS = $(LIBAPI) $(LIBTRACEEVENT) $(LIBSUBCMD) $(LIBPERF) ifndef NO_LIBBPF - PERFLIBS += $(LIBBPF) + ifndef LIBBPF_DYNAMIC + PERFLIBS += $(LIBBPF) + endif endif # We choose to avoid "if .. else if .. else .. endif endif" -- cgit v1.2.3-59-g8ed1b