diff --git a/Cargo.toml b/Cargo.toml index 04efe78a8..602ddf675 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,8 +50,12 @@ allow_attributes = "warn" # Cargo only looks at the profile settings # in the Cargo.toml manifest at the root of the workspace +[profile.dev] +panic = "unwind" + [profile.release] lto = "thin" +panic = "unwind" # Release profile configuration with Link Time Optimization (LTO) enabled. # diff --git a/osdk/src/commands/build/mod.rs b/osdk/src/commands/build/mod.rs index c862ccbd4..1b241f294 100644 --- a/osdk/src/commands/build/mod.rs +++ b/osdk/src/commands/build/mod.rs @@ -207,9 +207,8 @@ fn build_kernel_elf( &rustc_linker_script_arg, "-C relocation-model=static", "-C relro-level=off", - // We do not really allow unwinding except for kernel testing. However, we need to specify - // this to show backtraces when panicking. - "-C panic=unwind", + // Even if we disabled unwinding on panic, we need to specify this to show backtraces. + "-C force-unwind-tables=yes", // This is to let rustc know that "cfg(ktest)" is our well-known configuration. // See the [Rust Blog](https://blog.rust-lang.org/2024/05/06/check-cfg.html) for details. "--check-cfg cfg(ktest)", diff --git a/osdk/src/commands/test.rs b/osdk/src/commands/test.rs index 701351acb..aa0d2a612 100644 --- a/osdk/src/commands/test.rs +++ b/osdk/src/commands/test.rs @@ -98,7 +98,7 @@ pub static KTEST_CRATE_WHITELIST: Option<&[&str]> = Some(&{:#?}); &cargo_target_directory, config, ActionChoice::Test, - &["--cfg ktest"], + &["--cfg ktest", "-C panic=unwind"], ); std::env::remove_var("RUSTFLAGS"); drop(dir_guard);