retis-org / retis

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

build.rs: add error hint when build before making ebpf #358

Closed liuhangbin closed 8 months ago

liuhangbin commented 8 months ago

Since #237 the BPF part is not handled by cargo build anymore. Users who are not aware of this and run cargo build directly will get error:

  --- 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

The users could not get what should do to avoid this error. Let's add an error hint so they can know how to avoid it. Here is what it looks like:

  --- stderr
  thread 'main' panicked at build.rs:48:17:
  Unable to find src/core/probe/kernel/bpf/.out/kprobe.skel.rs, please try 'make ebpf' first

  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
liuhangbin commented 8 months ago

Don't we need the same improved error message in gen_hook_skel?

After make ebpf, cargo build will pass. So I think there is no need to add another hit.

atenart commented 8 months ago

Don't we need the same improved error message in gen_hook_skel?

After make ebpf, cargo build will pass. So I think there is no need to add another hit.

That's right. But we might change the order of the calls in build.rs; or someone could manually remove one of the BPF object files, etc. I agree those are not likely events, but having the right error message from the beginning will help maintenance.