retis-org / retis

Tracing packets in the Linux networking stack & friends
https://retis.readthedocs.io/en/stable/
100 stars 14 forks source link

failed to generate `src/core/probe/kernel/bpf/.out/kprobe.bpf.o` #356

Closed liuhangbin closed 9 months ago

liuhangbin commented 9 months ago

Cargo build failed with the following error when I built it on RHEL9

# uname -r
5.14.0-323.el9.x86_64
# cargo build
   Compiling retis v1.3.1 (/root/retis)
error: failed to run custom build command for `retis v1.3.1 (/root/retis)`

Caused by:
  process didn't exit successfully: `/root/retis/target/debug/build/retis-45d8835b6563a9b1/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=TARGET
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
  cargo:rerun-if-changed=src/core/bpf_sys/include/bpf-sys.h
  cargo:rerun-if-changed=src/core/bpf_sys/include/linux/bpf.h
  cargo:rerun-if-changed=/usr/include/linux/types.h
  cargo:rerun-if-changed=/usr/include/asm/types.h
  cargo:rerun-if-changed=/usr/include/asm-generic/types.h
  cargo:rerun-if-changed=/usr/include/asm-generic/int-ll64.h
  cargo:rerun-if-changed=/usr/include/asm/bitsperlong.h
  cargo:rerun-if-changed=/usr/include/asm-generic/bitsperlong.h
  cargo:rerun-if-changed=/usr/include/linux/posix_types.h
  cargo:rerun-if-changed=/usr/include/linux/stddef.h
  cargo:rerun-if-changed=/usr/include/asm/posix_types.h
  cargo:rerun-if-changed=/usr/include/asm/posix_types_64.h
  cargo:rerun-if-changed=/usr/include/asm-generic/posix_types.h
  cargo:rerun-if-changed=/usr/include/asm/bitsperlong.h
  cargo:rerun-if-changed=src/core/bpf_sys/include/linux/bpf_common.h
  cargo:rerun-if-changed=src/core/bpf_sys/include/linux/filter.h
  cargo:rerun-if-changed=/usr/include/linux/types.h
  cargo:rerun-if-changed=src/core/bpf_sys/include/linux/bpf_common.h

  --- stderr
  thread 'main' panicked at build.rs:46:9:
  failed to generate `src/core/probe/kernel/bpf/.out/kprobe.bpf.o`

  Caused by:
      0: Failed to generate skeleton for src/core/probe/kernel/bpf/.out/kprobe.bpf.o
      1: No such file or directory (os error 2)
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

# git bisect bad
43f3165f5349ef012b4bf2fc84b1b9cc6d7f2f94 is the first bad commit
commit 43f3165f5349ef012b4bf2fc84b1b9cc6d7f2f94
Author: Paolo Valerio <pvalerio@redhat.com>
Date:   Tue Feb 6 18:00:00 2024 +0100

    build.rs: split tool and ebpf program build

    Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
atenart commented 9 months ago

I'm pretty sure this is due to #237 because now the BPF part is not handled by cargo build anymore. You know should use make instead (-j X can be used now too!). See make help for more details.

Having said that, the error is not straightforward to understand (the file is missing, but why?). @vlrpl do you think we could add a check in gen_probe/hook_skel in build.rs to fail if the BPF object files are not found, with an improved error message?

vlrpl commented 9 months ago

I'm pretty sure this is due to #237 because now the BPF part is not handled by cargo build anymore. You know should use make instead (-j X can be used now too!). See make help for more details.

yes, it's due to that

Having said that, the error is not straightforward to understand (the file is missing, but why?). @vlrpl do you think we could add a check in gen_probe/hook_skel in build.rs to fail if the BPF object files are not found, with an improved error message?

if .bpf.o is missing it is because it was not compiled. I guess we can suggest running make help or something like that. Some nits will be changed to build.rs, so we can use that PR to wrap the error. Alternatively, it is fine to add the message in another PR (feel free to pick this up).

@liuhangbin, if it's ok for you, I guess this can be closed.

atenart commented 9 months ago

I guess we can suggest running make help or something like that.

I'd suggest something like "path/file.o is missing, please compile it first by using make ebpf. See make help for more details."

Some nits will be changed to build.rs, so we can use that PR to wrap the error. Alternatively, it is fine to add the message in another PR (feel free to pick this up).

Sounds good.

liuhangbin commented 9 months ago

Having said that, the error is not straightforward to understand (the file is missing, but why?).

Yes, I can't see what I should do to fix it from the error message.

I'd suggest something like "path/file.o is missing, please compile it first by using make ebpf. See make help for more details."

Makes sense to me.

@liuhangbin, if it's ok for you, I guess this can be closed.

Sure