Re: init_disassemble_info() signature changes causes compile failures

From: Quentin Monnet
Date: Wed Jun 22 2022 - 18:54:39 EST


On Wed, 22 Jun 2022 at 19:19, Andres Freund <andres@xxxxxxxxxxx> wrote:
>
> Hi,
>
> binutils changed the signature of init_disassemble_info(), which now causes
> perf and bpftool to fail to compile (e.g. on debian unstable).
>
> Relevant binutils commit: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=60a3da00bd5407f07d64dff82a4dae98230dfaac
>
> util/annotate.c: In function ‘symbol__disassemble_bpf’:
> util/annotate.c:1765:9: error: too few arguments to function ‘init_disassemble_info’
> 1765 | init_disassemble_info(&info, s,
> | ^~~~~~~~~~~~~~~~~~~~~
> In file included from util/annotate.c:1718:
> /usr/include/dis-asm.h:472:13: note: declared here
> 472 | extern void init_disassemble_info (struct disassemble_info *dinfo, void *stream,
> | ^~~~~~~~~~~~~~~~~~~~~
>
> with equivalent failures in
>
> tools/bpf/bpf_jit_disasm.c
> tools/bpf/bpftool/jit_disasm.c

Hi Andres,

Too bad the libbfd API is changing again :/ But many thanks for
pinning down the relevant commit, and for the report!

> The fix is easy enough, add a wrapper around fprintf() that conforms to the
> new signature.
>
> However I assume the necessary feature test and wrapper should only be added
> once? I don't know the kernel stuff well enough to choose the right structure
> here.

We can probably find a common header for the wrapper under
tools/include/. One possibility could be a new header under
tools/include/tools/, like for libc_compat.h. Although personally I
don't mind too much about redefining the wrapper several times given
how short it is, and because maybe some tools could redefine it anyway
to use colour output in the future.

The feature test would better be shared, it would probably be similar
to what was done in the following commit to accommodate for a previous
change in libbfd:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fb982666e380c1632a74495b68b3c33a66e76430

> Attached is my local fix for perf. Obviously would need work to be a real
> solution.

Thanks a lot! Would you be willing to submit a patch for the feature
detection and wrapper?

Best regards,
Quentin