Re: [PATCH bpf-next v4 2/2] bpftool: Make the LLVM disassembler an optional runtime dependency
From: Alexei Starovoitov
Date: Mon Nov 02 2026 - 23:35:46 EST
On Mon, Nov 02, 2026 at 04:44 AM Mark Korenberg via B4 Relay <devnull+socketpair.gmail.com@xxxxxxxxxx> wrote:
> + else ifeq ($(words $(LIBLLVM_SO)),1)
> + # Don't link with libLLVM.so. "prog dump jited" loads it with dlopen().
> + CFLAGS += -DLIBLLVM_SO='"$(notdir $(realpath $(LIBLLVM_SO)))"'
sashiko is right. realpath was my suggestion, sorry.
Today DT_NEEDED of bpftool has the soname of libLLVM.so.
Every distro makes that name visible to ld.so.
The name of the file behind it is up to the distro.
The two are the same on Fedora 44, where you tested.
Where they differ dlopen() fails and "prog dump jited" doesn't work at all.
Pls use the soname. Something like this (not tested):
LIBLLVM_SONAME := $(shell $(READELF) -d $(LIBLLVM_SO) | \
sed -n 's/.*(SONAME).*\[\(.*\)\].*/\1/p')
CFLAGS += -DLIBLLVM_SO='"$(LIBLLVM_SONAME)"'
[...]
> + lib = dlopen(LIBLLVM_SO, RTLD_NOW);
> + if (!lib) {
> + p_err("failed to load %s: %s", LIBLLVM_SO,
> + dlerror() ?: "unknown error");
> + return -1;
> + }
"bpftool prog dump jited id N file F" fails here too when libLLVM.so is
not installed. It doesn't need a disassembler.
prog_dump() only writes the image to F.
But do_dump() calls disasm_init() before it parses "file".
Call disasm_init() after the arguments are parsed, and only without "file" ?
It can be a separate patch.
Also common_options.rst still says "linking against LLVM".
pw-bot: cr