RE: Build error of samples/bpf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Thanks,
Oak

> -----Original Message-----
> From: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx>
> Sent: July 13, 2022 2:21 PM
> To: Zeng, Oak <oak.zeng@xxxxxxxxx>
> Cc: bpf@xxxxxxxxxxxxxxx
> Subject: Re: Build error of samples/bpf
> 
> On Tue, 12 Jul 2022 at 16:10, Zeng, Oak <oak.zeng@xxxxxxxxx> wrote:
> >
> > Hello all,
> >
> > I tried to build the latest samples/bpf following instructions in the
> README.rst in samples/bpf folder. I ran into various issue such as:
> >
> > samples/bpf/Makefile:375: *** Cannot find a vmlinux for VMLINUX_BTF at
> any of "  /home/szeng/dii-tools/linux/vmlinux", build the kernel or set
> VMLINUX_BTF or VMLINUX_H variable
> >
> > I was able to fix above issue by enable CONFIG_DEBUG_INFO_BTF in
> kernel .config file.
> >
> > But I eventually ran into other errors.  I had to fix those errors by install
> dwarves, updating my clang/llvm to version 10.
> >
> > I was able to build it if I comment out all the xdp programs from Makefile. It
> seems those xdp programs require advanced features such as data structure
> layout in vmlinux.h (dumped from vmlinux using bpftool) and this require
> special kernel config support.
> >
> > So I thought instead of fixing those errors one by one, I should ask those
> who are working in this area, is there any instructions on how to build
> samples/bpf? The README.rst seems out-of-date, for example, it doesn't
> mention CONFIG_DEBUG_INFO_BTF. The required llvm/clang version in
> README.rst is also out-of-date.
> >
> > More specifically, to build samples/bpf, is there an example kernel .config
> to use? I tried those config here
> https://github.com/torvalds/linux/blob/master/tools/testing/selftests/bpf/c
> onfig but build errors persist.
> >
> > Or is there any other tools I need to install/update on my system?
> >
> > My whole build log is as below:
> >
> > szeng@linux:~/dii-tools/linux$ make M=samples/bpf
> > readelf: Error: Missing knowledge of 32-bit reloc types used in DWARF
> sections of machine number 247
> > readelf: Warning: unable to apply unsupported reloc type 10 to
> section .debug_info
> > readelf: Warning: unable to apply unsupported reloc type 1 to
> section .debug_info
> > readelf: Warning: unable to apply unsupported reloc type 10 to
> section .debug_info make -C /home/szeng/dii-
> tools/linux/samples/bpf/../../tools/lib/bpf RM='rm -rf' EXTRA_CFLAGS="-
> Wall -O2 -Wmissing-prototypes -Wstrict-prototypes -I./usr/include -
> I./tools/testing/selftests/bpf/ -I/home/szeng/dii-
> tools/linux/samples/bpf/libbpf/include -I./tools/include -I./tools/perf -
> DHAVE_ATTR_TEST=0" \
> >         LDFLAGS= srctree=/home/szeng/dii-tools/linux/samples/bpf/../../ \
> >         O= OUTPUT=/home/szeng/dii-tools/linux/samples/bpf/libbpf/
> DESTDIR=/home/szeng/dii-tools/linux/samples/bpf/libbpf prefix= \
> >         /home/szeng/dii-tools/linux/samples/bpf/libbpf/libbpf.a
> install_headers
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/libbpf.o
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/bpf.o
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/nlattr.o
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/btf.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/libbpf_errno.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/str_error.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/netlink.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/bpf_prog_linfo.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/libbpf_probes.o
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/xsk.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/hashmap.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/btf_dump.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/ringbuf.o
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/strset.o
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/linker.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/gen_loader.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/relo_core.o
> >   LD      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/libbpf-
> in.o
> >   LINK    /home/szeng/dii-tools/linux/samples/bpf/libbpf/libbpf.a
> >   INSTALL headers
> >   CC  samples/bpf/test_lru_dist
> >   CC  samples/bpf/sock_example
> >   CC  samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.o
> >   CC  samples/bpf/../../tools/testing/selftests/bpf/trace_helpers.o
> >   CC  samples/bpf/cookie_uid_helper_example.o
> >   CC  samples/bpf/cpustat_user.o
> >   CC  samples/bpf/fds_example.o
> >   CC  samples/bpf/hbm.o
> >   CC  samples/bpf/i915_latency_hist_user.o
> >   CC  samples/bpf/i915_stat_user.o
> >   CC  samples/bpf/ibumad_user.o
> >   CC  samples/bpf/lathist_user.o
> >   CC  samples/bpf/lwt_len_hist_user.o
> >   CC  samples/bpf/map_perf_test_user.o
> >   CC  samples/bpf/offwaketime_user.o
> >   CC  samples/bpf/sampleip_user.o
> >   CC  samples/bpf/sockex1_user.o
> >   CC  samples/bpf/sockex2_user.o
> >   CC  samples/bpf/sockex3_user.o
> >   CC  samples/bpf/spintest_user.o
> >   CC  samples/bpf/syscall_tp_user.o
> >   CC  samples/bpf/task_fd_query_user.o
> >   CC  samples/bpf/tc_l2_redirect_user.o
> >   CC  samples/bpf/test_cgrp2_array_pin.o
> >   CC  samples/bpf/test_cgrp2_attach.o
> >   CC  samples/bpf/test_cgrp2_sock.o
> >   CC  samples/bpf/test_cgrp2_sock2.o
> >   CC  samples/bpf/test_current_task_under_cgroup_user.o
> >   CC  samples/bpf/test_map_in_map_user.o
> >   CC  samples/bpf/test_overhead_user.o
> >   CC  samples/bpf/test_probe_write_user_user.o
> >   CC  samples/bpf/trace_event_user.o
> >   CC  samples/bpf/trace_output_user.o
> >   CC  samples/bpf/tracex1_user.o
> >   CC  samples/bpf/tracex2_user.o
> >   CC  samples/bpf/tracex3_user.o
> >   CC  samples/bpf/tracex4_user.o
> >   CC  samples/bpf/tracex5_user.o
> >   CC  samples/bpf/tracex6_user.o
> >   CC  samples/bpf/tracex7_user.o
> >   CC  samples/bpf/xdp1_user.o
> >   CC  samples/bpf/xdp_adjust_tail_user.o
> >   CC  samples/bpf/xdp_fwd_user.o
> > make -C /home/szeng/dii-tools/linux/samples/bpf/../../tools/bpf/bpftool
> srctree=/home/szeng/dii-tools/linux/samples/bpf/../../ \
> >         OUTPUT=/home/szeng/dii-tools/linux/samples/bpf/bpftool/ \
> >         LIBBPF_OUTPUT=/home/szeng/dii-tools/linux/samples/bpf/libbpf/ \
> >         LIBBPF_DESTDIR=/home/szeng/dii-tools/linux/samples/bpf/libbpf/
> >
> > Auto-detecting system features:
> > ...                        libbfd: [ OFF ]
> > ...        disassembler-four-args: [ OFF ]
> > ...                          zlib: [ on  ]
> > ...                        libcap: [ OFF ]
> > ...               clang-bpf-co-re: [ on  ]
> >
> >
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/libbpf.o
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/bpf.o
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/nlattr.o
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/btf.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/libbpf_errno.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/str_error.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/netlink.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/bpf_prog_linfo.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/libbpf_probes.o
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/xsk.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/hashmap.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/btf_dump.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/ringbuf.o
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/strset.o
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/linker.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/gen_loader.o
> >   CC      /home/szeng/dii-
> tools/linux/samples/bpf/libbpf/staticobjs/relo_core.o
> >   LD      /home/szeng/dii-tools/linux/samples/bpf/libbpf/staticobjs/libbpf-
> in.o
> >   LINK    /home/szeng/dii-tools/linux/samples/bpf/libbpf/libbpf.a
> >   CLANG   /home/szeng/dii-tools/linux/samples/bpf/bpftool/profiler.bpf.o
> >   GEN     /home/szeng/dii-tools/linux/samples/bpf/bpftool/profiler.skel.h
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/bpftool/prog.o
> >   CLANG   /home/szeng/dii-tools/linux/samples/bpf/bpftool/pid_iter.bpf.o
> >   GEN     /home/szeng/dii-tools/linux/samples/bpf/bpftool/pid_iter.skel.h
> >   CC      /home/szeng/dii-tools/linux/samples/bpf/bpftool/pids.o
> >   LINK    /home/szeng/dii-tools/linux/samples/bpf/bpftool/bpftool
> >   CC  samples/bpf/xdp_router_ipv4_user.o
> >   CC  samples/bpf/xdp_rxq_info_user.o
> >   CC  samples/bpf/xdp_sample_pkts_user.o
> >   CC  samples/bpf/xdp_tx_iptunnel_user.o
> >   CC  samples/bpf/xdpsock_ctrl_proc.o
> >   CC  samples/bpf/xsk_fwd.o
> >   CLANG-BPF  samples/bpf/xdp_sample.bpf.o
> >   CLANG-BPF  samples/bpf/xdp_redirect_map_multi.bpf.o
> >   CLANG-BPF  samples/bpf/xdp_redirect_cpu.bpf.o
> >   CLANG-BPF  samples/bpf/xdp_redirect_map.bpf.o
> >   CLANG-BPF  samples/bpf/xdp_monitor.bpf.o
> >   CLANG-BPF  samples/bpf/xdp_redirect.bpf.o
> >   BPF GEN-OBJ  samples/bpf/xdp_monitor
> >   BPF GEN-SKEL samples/bpf/xdp_monitor
> > libbpf: map 'rx_cnt': unexpected def kind var.
> 
> IIRC, this error is due to older clang. Can you try with a newer clang
> (11 and above)?

Thank you Kumar.

I updated to llvm/clang to version 12, the issue persists. 

I also have another problem... To build those xdp samples, I need to enable CONFIG_DEBUG_INFO_BTF. But once this is enabled, I failed to build linux kernel with below errors. I was able to build on a 4.15 ubuntu machine but on a 5.11  ubuntu machine, I had below error to build the same kernel. Any one can give me some hint? I searched google but didn't figure out. I noticed somethings is killed during build of .bpf.vmlinux.bin.o, so I guess some of my tools is not updated?



szeng@szeng-develop:~/dii-tools/linux$ make -j$(nproc)
  DESCEND objtool
  DESCEND bpf/resolve_btfids
  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  AR      init/built-in.a
  CHK     kernel/kheaders_data.tar.xz
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  AR      init/built-in.a
  LD      vmlinux.o
  MODPOST vmlinux.symvers
  MODINFO modules.builtin.modinfo
  GEN     modules.builtin
  LD      .tmp_vmlinux.btf
  BTF     .btf.vmlinux.bin.o
Killed
  LD      .tmp_vmlinux.kallsyms1
  KSYMS   .tmp_vmlinux.kallsyms1.S
  AS      .tmp_vmlinux.kallsyms1.S
  LD      .tmp_vmlinux.kallsyms2
  KSYMS   .tmp_vmlinux.kallsyms2.S
  AS      .tmp_vmlinux.kallsyms2.S
  LD      vmlinux
  BTFIDS  vmlinux
FAILED: load BTF from vmlinux: No such file or directory
make: *** [Makefile:1183: vmlinux] Error 255
make: *** Deleting file 'vmlinux'


Thanks,
Oak

> 
> > Error: failed to open BPF object file: Invalid argument
> > samples/bpf/Makefile:430: recipe for target
> 'samples/bpf/xdp_monitor.skel.h' failed
> > make[1]: *** [samples/bpf/xdp_monitor.skel.h] Error 255
> > make[1]: *** Deleting file 'samples/bpf/xdp_monitor.skel.h'
> > Makefile:1868: recipe for target 'samples/bpf' failed
> > make: *** [samples/bpf] Error 2
> >
> >
> > Thanks,
> > Oak
> >




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux