2023-05-12 14:59 UTC+0200 ~ Jiri Olsa <olsajiri@xxxxxxxxx> > On Fri, May 12, 2023 at 11:33:54AM +0100, Quentin Monnet wrote: >> From: Alexander Lobakin <alobakin@xxxxx> >> >> Fix the following error when building bpftool: >> >> CLANG profiler.bpf.o >> CLANG pid_iter.bpf.o >> skeleton/profiler.bpf.c:18:21: error: invalid application of 'sizeof' to an incomplete type 'struct bpf_perf_event_value' >> __uint(value_size, sizeof(struct bpf_perf_event_value)); >> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> tools/bpf/bpftool/bootstrap/libbpf/include/bpf/bpf_helpers.h:13:39: note: expanded from macro '__uint' >> tools/bpf/bpftool/bootstrap/libbpf/include/bpf/bpf_helper_defs.h:7:8: note: forward declaration of 'struct bpf_perf_event_value' >> struct bpf_perf_event_value; >> ^ >> >> struct bpf_perf_event_value is being used in the kernel only when >> CONFIG_BPF_EVENTS is enabled, so it misses a BTF entry then. > > hi, > when I switch off CONFIG_BPF_EVENTS the bpftool build fails for me > with missing BTF error: > > GEN vmlinux.h > libbpf: failed to find '.BTF' ELF section in /home/jolsa/kernel/linux-qemu/vmlinux > Error: failed to load BTF from /home/jolsa/kernel/linux-qemu/vmlinux: No data available > make: *** [Makefile:208: vmlinux.h] Error 195 > make: *** Deleting file 'vmlinux.h' > > so I wonder you need to care about bpf_perf_event_value > in that case > > jirka Coming back to this - I haven't been able to reproduce. I turned CONFIG_BPF_EVENTS off but had the vmlinux.h building fine in my case, and applying the patchset fixes the build for bpftool. Is there any chance your .../vmlinux was not generated correctly? I'll re-submit the series after addressing Yonghong's feedback on the commit log. Thanks, Quentin