force-unwind-tables=yes instead of panic=unwind

This commit is contained in:
Zhang Junyang 2025-03-19 14:01:10 +08:00 committed by Tate, Hongliang Tian
parent 9c10568a73
commit 2bcc13a9e2
3 changed files with 7 additions and 4 deletions

View File

@ -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.
#

View File

@ -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)",

View File

@ -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);