foniod / redbpf

Rust library for building and running BPF/eBPF modules
Apache License 2.0
1.71k stars 136 forks source link

cargo install cargo-bpf failed #368

Closed bestgopher closed 1 year ago

bestgopher commented 1 year ago

When I installed the cargo-bpf, I got some errors.

error: failed to run custom build command for `bpf-sys v2.3.0`

Caused by:
  process didn't exit successfully: `/tmp/cargo-install831KIh/release/build/bpf-sys-32afe51597e8453b/build-script-build` (exit status: 101)
  --- stdout
  cargo:rustc-link-search=native=/tmp/cargo-install831KIh/release/build/bpf-sys-543d9bd5d6b1269e/out
  cargo:rustc-link-lib=static=bpf
  cargo:rustc-link-lib=elf
  cargo:rustc-link-lib=z
  cargo:rerun-if-changed=libbpf/
  cargo:rerun-if-changed=libbpf/src/bpf.c
  cargo:rerun-if-changed=libbpf/src/bpf_prog_linfo.c
  cargo:rerun-if-changed=libbpf/src/btf.c
  cargo:rerun-if-changed=libbpf/src/btf_dump.c
  cargo:rerun-if-changed=libbpf/src/gen_loader.c
  cargo:rerun-if-changed=libbpf/src/hashmap.c
  cargo:rerun-if-changed=libbpf/src/libbpf.c
  cargo:rerun-if-changed=libbpf/src/libbpf_errno.c
  cargo:rerun-if-changed=libbpf/src/libbpf_probes.c
  cargo:rerun-if-changed=libbpf/src/linker.c
  cargo:rerun-if-changed=libbpf/src/netlink.c
  cargo:rerun-if-changed=libbpf/src/nlattr.c
  cargo:rerun-if-changed=libbpf/src/ringbuf.c
  cargo:rerun-if-changed=libbpf/src/str_error.c
  cargo:rerun-if-changed=libbpf/src/strset.c
  cargo:rerun-if-changed=libbpf/src/xsk.c
  cargo:rerun-if-changed=libbpf/include/asm/barrier.h
  cargo:rerun-if-changed=libbpf/include/linux/compiler.h
  cargo:rerun-if-changed=libbpf/include/linux/err.h
  cargo:rerun-if-changed=libbpf/include/linux/filter.h
  cargo:rerun-if-changed=libbpf/include/linux/kernel.h
  cargo:rerun-if-changed=libbpf/include/linux/list.h
  cargo:rerun-if-changed=libbpf/include/linux/overflow.h
  cargo:rerun-if-changed=libbpf/include/linux/ring_buffer.h
  cargo:rerun-if-changed=libbpf/include/linux/types.h
  cargo:rerun-if-changed=libbpf/include/uapi/linux/bpf.h
  cargo:rerun-if-changed=libbpf/include/uapi/linux/bpf_common.h
  cargo:rerun-if-changed=libbpf/include/uapi/linux/btf.h
  cargo:rerun-if-changed=libbpf/include/uapi/linux/if_link.h
  cargo:rerun-if-changed=libbpf/include/uapi/linux/if_xdp.h
  cargo:rerun-if-changed=libbpf/include/uapi/linux/netlink.h
  cargo:rerun-if-changed=libbpf/include/uapi/linux/pkt_cls.h
  cargo:rerun-if-changed=libbpf/include/uapi/linux/pkt_sched.h
  cargo:rerun-if-changed=libbpf/src/bpf.h
  cargo:rerun-if-changed=libbpf/src/bpf_core_read.h
  cargo:rerun-if-changed=libbpf/src/bpf_endian.h
  cargo:rerun-if-changed=libbpf/src/bpf_gen_internal.h
  cargo:rerun-if-changed=libbpf/src/bpf_helper_defs.h
  cargo:rerun-if-changed=libbpf/src/bpf_helpers.h
  cargo:rerun-if-changed=libbpf/src/bpf_tracing.h
  cargo:rerun-if-changed=libbpf/src/btf.h
  cargo:rerun-if-changed=libbpf/src/hashmap.h
  cargo:rerun-if-changed=libbpf/src/libbpf.h
  cargo:rerun-if-changed=libbpf/src/libbpf_common.h
  cargo:rerun-if-changed=libbpf/src/libbpf_internal.h
  cargo:rerun-if-changed=libbpf/src/libbpf_legacy.h
  cargo:rerun-if-changed=libbpf/src/nlattr.h
  cargo:rerun-if-changed=libbpf/src/skel_internal.h
  cargo:rerun-if-changed=libbpf/src/str_error.h
  cargo:rerun-if-changed=libbpf/src/strset.h
  cargo:rerun-if-changed=libbpf/src/xsk.h
  cargo:rerun-if-changed=libbpf/travis-ci/vmtest/vmlinux.h
  cargo:rerun-if-changed=libbpf/travis-ci/managers/travis_wait.bash
  cargo:rerun-if-changed=libbpf/src/libbpf.map
  cargo:rerun-if-changed=libbpf/README.md
  cargo:rerun-if-changed=libbpf/scripts/coverity.sh
  cargo:rerun-if-changed=libbpf/scripts/sync-kernel.sh
  cargo:rerun-if-changed=libbpf/travis-ci/managers/debian.sh
  cargo:rerun-if-changed=libbpf/travis-ci/managers/ubuntu.sh
  cargo:rerun-if-changed=libbpf/travis-ci/vmtest/build_pahole.sh
  cargo:rerun-if-changed=libbpf/travis-ci/vmtest/build_selftests.sh
  cargo:rerun-if-changed=libbpf/travis-ci/vmtest/checkout_latest_kernel.sh
  cargo:rerun-if-changed=libbpf/travis-ci/vmtest/helpers.sh
  cargo:rerun-if-changed=libbpf/travis-ci/vmtest/mkrootfs.sh
  cargo:rerun-if-changed=libbpf/travis-ci/vmtest/prepare_selftests-4.9.0.sh
  cargo:rerun-if-changed=libbpf/travis-ci/vmtest/prepare_selftests-5.5.0.sh
  cargo:rerun-if-changed=libbpf/travis-ci/vmtest/prepare_selftests.sh
  cargo:rerun-if-changed=libbpf/travis-ci/vmtest/run.sh
  cargo:rerun-if-changed=libbpf/travis-ci/vmtest/run_selftests.sh
  cargo:rerun-if-changed=libbpf/travis-ci/vmtest/run_vmtest.sh
  cargo:rerun-if-changed=libbpf/src/libbpf.pc.template
  cargo:rerun-if-changed=bpfsys-musl.h
  cargo:rerun-if-changed=libbpf_xdp.h
  make: Entering directory `/root/.cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/bpf-sys-2.3.0/libbpf/src'
    MKDIR    staticobjs
    CC       bpf.o
    CC       btf.o
    CC       libbpf.o
    CC       libbpf_errno.o
    CC       netlink.o
    CC       nlattr.o
    CC       str_error.o
    CC       libbpf_probes.o
    CC       bpf_prog_linfo.o
    CC       xsk.o
    CC       btf_dump.o
  make: Leaving directory `/root/.cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/bpf-sys-2.3.0/libbpf/src'

--- stderr
  btf_dump.c: In function ‘btf_dump_dump_type_data.isra.24’:
  btf_dump.c:2265:5: error: ‘err’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    if (err < 0)
       ^
  cc1: all warnings being treated as errors
  make: *** [/tmp/cargo-install831KIh/release/build/bpf-sys-543d9bd5d6b1269e/out/libbpf/staticobjs/btf_dump.o] Error 1
  thread 'main' panicked at 'failed to build `libbpf` static library', /root/.cargo/registry/src/rsproxy.cn-8f6827c7555bfaf8/bpf-sys-2.3.0/build.rs:56:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
cargo 1.70.0 (ec8a8a0ca 2023-04-25)
-> root@10-252-51-190 ~ ? # rustc --version --verbose
rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2
sn99 commented 1 year ago

@bestgopher Did you solve it?

bestgopher commented 1 year ago

@bestgopher Did you solve it?

Yes.

sn99 commented 1 year ago

@bestgopher Did you solve it?

Yes.

How if I may ask?

bestgopher commented 1 year ago

@bestgopher Did you solve it?

Yes.

How if I may ask?

Sorry, I forgot how to resove it. But I rebuilt the llvm compoments, you can try it.