From 8e746d08cd0cbb334a6cec9161206a69eb8cde45 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Mon, 24 Mar 2025 12:44:09 +1100 Subject: [PATCH] Use `target_arch = "bpf"` for `panic_handler`-cfg The `panic_handler` defined in the eBPF crate is only required if we are compiling for the bpf target. When compiling for the host-system, be it to run tests or by compiling the entire workspace with `cargo check --workspace` we don't want to define the `panic_handler`, otherwise it will clash with the one defined by the standard library. Related: https://github.com/aya-rs/book/issues/214 --- {{project-name}}-ebpf/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{project-name}}-ebpf/src/main.rs b/{{project-name}}-ebpf/src/main.rs index 64cfb70..a8232a2 100644 --- a/{{project-name}}-ebpf/src/main.rs +++ b/{{project-name}}-ebpf/src/main.rs @@ -319,7 +319,7 @@ fn try_{{crate_name}}(ctx: PerfEventContext) -> Result { } {%- endcase %} -#[cfg(not(test))] +#[cfg(target_arch = "bpf")] #[panic_handler] fn panic(_info: &core::panic::PanicInfo) -> ! { loop {}