Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile with panic = "abort" #1813

Merged
merged 2 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ wgpu-hal = { version = "0.15.4", default-features = false }


[profile.dev]
opt-level = 1 # Make debug builds run faster
opt-level = 1 # Make debug builds run faster
panic = "abort" # This leads to better optimizations and smaller binaries (and is the default in Wasm anyways).

# Optimize all dependencies even in debug builds (does not affect workspace packages):
[profile.dev.package."*"]
opt-level = 2

[profile.release]
# debug = true # good for profilers
panic = "abort" # This leads to better optimizations and smaller binaries (and is the default in Wasm anyways).

[profile.bench]
debug = true
Expand Down
2 changes: 2 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ disallowed-methods = [
"std::thread::spawn", # Use `std::thread::Builder` and name the thread

"sha1::Digest::new", # SHA1 is cryptographically broken

"std::panic::catch_unwind", # We compile with `panic = "abort"`
]

# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names
Expand Down
9 changes: 7 additions & 2 deletions crates/rerun/src/crash_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ fn install_panic_hook(_build_info: BuildInfo) {
format!("{file}:{}", location.line())
});

// `panic_info.message` is unstable, so this is the recommended way of getting
// the panic message out. We need both the `&str` and `String` variants.
let msg = panic_info_message(panic_info);

if let Some(msg) = &msg {
Expand Down Expand Up @@ -90,10 +88,17 @@ fn install_panic_hook(_build_info: BuildInfo) {
std::thread::sleep(std::time::Duration::from_secs(1)); // Give analytics time to send the event
}
}

// We compile with `panic = "abort"`, but we don't want to report the same problem twice, so just exit:
#[allow(clippy::exit)]
std::process::exit(102);
}));
}

fn panic_info_message(panic_info: &std::panic::PanicInfo<'_>) -> Option<String> {
// `panic_info.message` is unstable, so this is the recommended way of getting
// the panic message out. We need both the `&str` and `String` variants.

#[allow(clippy::manual_map)]
if let Some(msg) = panic_info.payload().downcast_ref::<&str>() {
Some((*msg).to_owned())
Expand Down