diff --git a/rust/compiler_builtins.rs b/rust/compiler_builtins.rs index cb4bbf7be4e313..6a2fbdb3061824 100644 --- a/rust/compiler_builtins.rs +++ b/rust/compiler_builtins.rs @@ -133,14 +133,3 @@ define_panicking_intrinsics!("`u64` division/modulo should not be used", { __aeabi_uldivmod, __mulodi4, }); - -extern "C" { - fn rust_helper_BUG() -> !; -} - -#[panic_handler] -fn panic(_info: &core::panic::PanicInfo<'_>) -> ! { - unsafe { - rust_helper_BUG(); - } -} diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs index 226af02dc825a8..b538d6209fed94 100644 --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@ -226,3 +226,14 @@ macro_rules! container_of { ptr.wrapping_offset(-offset) as *const $type }} } + +#[cfg(not(any(testlib, test)))] +#[panic_handler] +fn panic(info: &core::panic::PanicInfo<'_>) -> ! { + extern "C" { + fn rust_helper_BUG() -> !; + } + pr_emerg!("{}\n", info); + // SAFETY: FFI call. + unsafe { rust_helper_BUG() }; +}