Skip to content

perf/bpftool: Allow to link libbpf dynamically

Jiri Olsa bpf lkml netdev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest6 patches 22 repliesIn review
  2. v13 patches 22 repliesSuperseded

Changes in v4 from the cover letter

- based on Toke's v3 post, there's no need for additional API exports:

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6perf tools: Allow to specify libbpf install directorytools/perf/Makefile.config+20 -70 replies
2/6bpftool: Allow to link libbpf dynamicallytools/bpf/bpftool/Makefile+38 -00 replies
3/6bpftool: Rename BPF_DIR Makefile variable to LIBBPF_SRC_DIRtools/bpf/bpftool/Makefile+4 -40 replies
4/6bpftool: Rename LIBBPF_OUTPUT Makefile variable to LIBBPF_BUILD_OUTPUTtools/bpf/bpftool/Makefile+5 -50 replies
5/6bpftool: Rename LIBBPF_PATH Makefile variable to LIBBPF_BUILD_PATHtools/bpf/bpftool/Makefile+3 -30 replies
6/6selftests, bpftool: Add build test for libbpf dynamic linkingtools/testing/selftests/bpf/test_bpftool_build.sh+53 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCHv4 0/6] perf/bpftool: Allow to link libbpf dynamically

hi,
adding support to link bpftool with libbpf dynamically, and config change for perf.

It's now possible to use:

  $ make -C tools/bpf/bpftool/ LIBBPF_DYNAMIC=1

which will detect libbpf devel package and if found, link it with bpftool.

It's possible to use arbitrary installed libbpf:

  $ make -C tools/bpf/bpftool/ LIBBPF_DYNAMIC=1 LIBBPF_DIR=/tmp/libbpf/

I based this change on top of Arnaldo's perf/core, because it contains libbpf feature detection code as dependency.

Also available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
libbpf/dyn

v4 changes:
- based on Toke's v3 post, there's no need for additional API exports:

Since bpftool uses bits of libbpf that are not exported as public API in the .so version, we also pass in libbpf.a to the linker, which allows it to pick up the private functions from the static library without having to expose them as ABI.

- changing some Makefile variable names
- documenting LIBBPF_DYNAMIC and LIBBPF_DIR in the Makefile comment
- extending test_bpftool_build.sh with libbpf dynamic link

thanks,
jirka

---
Jiri Olsa (6):
perf tools: Allow to specify libbpf install directory
bpftool: Allow to link libbpf dynamically
bpftool: Rename BPF_DIR Makefile variable to LIBBPF_SRC_DIR
bpftool: Rename LIBBPF_OUTPUT Makefile variable to LIBBPF_BUILD_OUTPUT
bpftool: Rename LIBBPF_PATH Makefile variable to LIBBPF_BUILD_PATH selftests, bpftool: Add build test for libbpf dynamic linking

 tools/bpf/bpftool/Makefile                        | 54 ++++++++++++++++++++++++++++++++++++++++++++++--------
 tools/perf/Makefile.config                        | 27 ++++++++++++++++++++-------
 tools/testing/selftests/bpf/test_bpftool_build.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 119 insertions(+), 15 deletions(-)