BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: <socketpair@gmail.com>, "Quentin Monnet" <qmo@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Bill Wendling" <morbo@google.com>,
	"Justin Stitt" <justinstitt@google.com>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	"Ihor Solodrai" <ihor.solodrai@linux.dev>,
	"Nick Desaulniers" <ndesaulniers@google.com>
Cc: <linux-kernel@vger.kernel.org>, <bpf@vger.kernel.org>,
	<llvm@lists.linux.dev>
Subject: Re: [PATCH bpf-next v4 2/2] bpftool: Make the LLVM disassembler an optional runtime dependency
Date: Tue, 03 Nov 2026 04:35:32 +0000	[thread overview]
Message-ID: <DMLAOL0238CH.43SXF0SFHONW@gmail.com> (raw)
In-Reply-To: <20261102-bpftool-plugin-v4-2-5a853e973db9@gmail.com>

On Mon, Nov 02, 2026 at 04:44 AM Mark Korenberg via B4 Relay <devnull+socketpair.gmail.com@kernel.org> 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

      parent reply	other threads:[~2026-11-03  4:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 12:44 [PATCH bpf-next v4 0/2] bpftool: Make the LLVM disassembler an optional runtime dependency Mark Korenberg via B4 Relay
2026-11-02 12:44 ` [PATCH bpf-next v4 1/2] bpftool: Fix disposal of the LLVM disassembler context Mark Korenberg via B4 Relay
2026-11-02 12:44 ` [PATCH bpf-next v4 2/2] bpftool: Make the LLVM disassembler an optional runtime dependency Mark Korenberg via B4 Relay
2026-11-02 12:54   ` sashiko-bot
2026-11-03  4:35   ` Alexei Starovoitov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DMLAOL0238CH.43SXF0SFHONW@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=justinstitt@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=qmo@kernel.org \
    --cc=socketpair@gmail.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox