If I specify panic
like this, it works for all targets:
[profile.release]
panic = "abort"
I want to specify panic = "abort"
only for target=arm-linux-androideabi
.
If I specify panic
like this, it works for all targets:
[profile.release]
panic = "abort"
I want to specify panic = "abort"
only for target=arm-linux-androideabi
.
You will need to add a .cargo/config
to your project and use it to specify the panic settings instead of Cargo.toml:
[target.arm-linux-androideabi]
rustflags = ["-C", "panic=abort"]
The two main configuration headings you will want to look at are [target.$triple]
and [target.'cfg(...)']
.
There is another way you could try to accomplish this: add a custom panic handler, gather a stack-trace, parse the stack-trace to determine what library the panic occurred in, and then only abort if you detect it as having occurred within that library.
Is this hacky/brittle? Yes.
But the option is there if for some reason you want it!
Starting point:
panic::set_hook(Box::new(|info| {
//let stacktrace = Backtrace::capture();
let stacktrace = Backtrace::force_capture();
println!("Got panic. @info:{}\n@stackTrace:{}", info, stacktrace);
if guess_library_from_stacktrace(stacktrace) == "library-X" {
std::process::abort();
}
}));
Here is a GitHub comment with more details: https://github.com/tokio-rs/tokio/issues/2002#issuecomment-1020443386