bpftool: Make the LLVM disassembler an optional runtime dependency
Status from this message: This series was applied to bpf/bpf-next.git (master)
Get series with b4
b4 am [email protected] change-id 20260603-bpftool-plugin-c994bc3e0643Versions newest first
- v5 Latest3 patches 3 repliesApplied 3/3
- v42 patches 1 replySuperseded
- v32 patches 1 replySuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 2 patches | 0 replies | Superseded | |
| v1 | 1 patch | 1 reply | Superseded |
Changes in v5 from the cover letter
- Use the soname of libLLVM for dlopen(), not the name of the file it
points to, which is not in the ld.so path on Ubuntu 24.04 (Sashiko, Alexei)
- New patch 2: call disasm_init() only when the image is disassembled,
so that "prog dump jited ... file FILE" works without libLLVM (Alexei)
- Update common_options.rst, which still said that bpftool links with
LLVM (Alexei)
- Rebase on bpf-next
- Link to v4: https://lore.kernel.org/r/[email protected]
Patches in v5 All 3 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | bpftool: Fix disposal of the LLVM disassembler contexttools/ | +1 | 1 reply | Applied |
| 2/3 | bpftool: Don't require a disassembler to dump a JITed program to a filetools/ | +2 | 1 reply | Applied |
| 3/3 | bpftool: Make the LLVM disassembler an optional runtime dependencytools/ tools/ tools/ | +107 | 1 reply | Applied |
Reviews trailers per patch
All 3 patches have a Reviewed-by or Acked-by.
| Patch | Quentin Monnet |
|---|---|
| 1/3 | A-b |
| 2/3 | A-b |
| 3/3 | T-b A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH bpf-next v5 0/3] bpftool: Make the LLVM disassembler an optional runtime dependency
libLLVM (~140 MiB on Fedora) is a hard dependency of bpftool, although it is only used by "bpftool prog dump jited". With this series, bpftool is no longer linked with libLLVM.so but loads it with dlopen() when it needs to disassemble JITed programs, so that distributions can make it optional. Patch 1 fixes a leak found on the way. Patch 2 makes "prog dump jited ... file FILE" work without a disassembler.
Changes in v5:
- Use the soname of libLLVM for dlopen(), not the name of the file it
points to, which is not in the ld.so path on Ubuntu 24.04 (Sashiko, Alexei)
- New patch 2: call disasm_init() only when the image is disassembled,
so that "prog dump jited ... file FILE" works without libLLVM (Alexei)
- Update common_options.rst, which still said that bpftool links with
LLVM (Alexei)
- Rebase on bpf-next
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Drop the plugin, load libLLVM.so with dlopen() instead, as suggested by Alexei. This also makes "prog dump jited" work with the bpftool built by selftests.
- Keep "llvm" in "bpftool version" a build time feature (Alexei)
- Unlike the suggested diff, still link with LLVM built with BUILD_SHARED_LIBS=ON, rather than failing to build
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Look for the plugin next to the bpftool binary before its install directory, so that bpftool run from its build directory does not pick
an older installed plugin (Sashiko)
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Move the LLVMDisasmDispose() fix to a separate patch (Quentin)
- Look for the plugin next to the bpftool binary when it is not installed, so that bpftool works from its build directory (Quentin, Sashiko). Not in the current directory: bpftool usually runs as root.
- Export a single versioned structure of callbacks from the plugin (Quentin)
- Only report "llvm" in "bpftool version" if the plugin loads (Quentin)
- Handle dlerror() returning NULL (Quentin)
- Rebuild jit_disasm.o if libdir changes between "make" and
"make install" (Quentin)
- uninstall: use QUIET_UNINST, remove $(libdir)/bpftool (Quentin)
- With a static libLLVM, which a static bpftool requires, link the disassembler into bpftool as before (Sashiko). This drops
LLVM_LINK_STATIC: static LLVM archives are never linked into a shared object.
- Commit log and comment fixes (Quentin, Sashiko)
- Rebase on bpf-next
- Link to v1: https://lore.kernel.org/r/[email protected]
Tested on Fedora 44 x86_64, LLVM 22: builds with shared, static and per-component LLVM, and with SKIP_LLVM; "prog dump jited" (plain, JSON and to a file) on live programs; bpftool, also when installed as selftests do, loads libLLVM.so only for "prog dump jited" and reports an error if it is missing; "prog dump jited ... file" works without a disassembler. Also tested with Ubuntu 24.04 (LLVM 18) userspace, where bpftool now loads libLLVM.so.18.1 (v4 tried libLLVM.so.1).
The changes since v1 were written with the help of an AI assistant (Claude), from the review comments; I reviewed and tested them.
---
Mark Korenberg (3):
bpftool: Fix disposal of the LLVM disassembler context
bpftool: Don't require a disassembler to dump a JITed program to a file
bpftool: Make the LLVM disassembler an optional runtime dependency
tools/bpf/bpftool/Documentation/common_options.rst | 10 ++- tools/bpf/bpftool/Makefile | 16 +++- tools/bpf/bpftool/jit_disasm.c | 88 +++++++++++++++++++++- tools/bpf/bpftool/prog.c | 4 +- 4 files changed, 110 insertions(+), 8 deletions(-)
---
base-commit: cd5bc55288d4fd999595c8f2af6a5408cbe92a52
change-id: 20260603-bpftool-plugin-c994bc3e0643
Best regards,
Signature · 1 line
Mark Korenberg <[email protected]>