Re: [PATCH v1 1/3] perf build: Remove libbfd support

From: Ian Rogers
Date: Tue Jan 21 2025 - 11:52:47 EST


On Mon, Jan 13, 2025 at 7:10 AM Arnaldo Carvalho de Melo
<acme@xxxxxxxxxx> wrote:
>
> On Sat, Jan 11, 2025 at 12:28:49PM -0800, Ian Rogers wrote:
> > libbfd is license incompatible with perf and building requires the
> > BUILD_NONDISTRO=1 build flag. Remove the code to simplify the code
> > base.
> >
> > Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
>
> > diff --git a/tools/perf/util/disasm_bpf.c b/tools/perf/util/disasm_bpf.c
> > index 1fee71c79b62..a891a0b909a7 100644
> > --- a/tools/perf/util/disasm_bpf.c
> > -
> > -int symbol__disassemble_bpf(struct symbol *sym, struct annotate_args *args)
> > -{
> > - struct annotation *notes = symbol__annotation(sym);
>
> Song,
>
> Have you ever investigated how to reimplement BPF disassemble
> using some other library than this one?

I think doing it using libLLVM should be straightforward. I sent out
this series to make libcapstone and libLLVM loadable using
dlopen/dlsym:
https://lore.kernel.org/lkml/20250120173208.344231-1-irogers@xxxxxxxxxx/
See symbol__disassemble_llvm in patch 5:
https://lore.kernel.org/lkml/20250120173208.344231-6-irogers@xxxxxxxxxx/
the difference is selecting just the BPF disassembler, so don't pass a
triplet, force it to BPF.

Anyway, one option following that series is to factor libbfd
dependencies into a bfd.c in tools/perf/util. That way we can try to
have a common interface for capstone, LLVM, etc. The other is to
delete it, which is my preference. I can add the BPF disassembler
support to llvm.c in that series and rebase this series onto it.

Thanks,
Ian

> Thanks,
>
> - Arnaldo