I have a crate producing both a
[[bin]] that runs as a server process and
[lib] target with shared code for clients. The primary use of the lib is
as cdylib linked into various C and C++ binaries.
Currently the crate builds with
panic = "abort" which is the desired behavior
for the server binary, but rather unsuitable for the
[lib] used by
clients as policing potential panics in dependencies is way out of scope.
Thus I would like to switch the library – and only the library! – to
panic = "unwind"
and guard the FFI boundary with
std::panic::catch_unwind. (Note that this is not
intended as a discussion of the merits of unwinding!)
Browsing the Cargo docs I couldn’t find a way of specifying the panic behavior
per target. There’s profiles sure but they apply to the crate as a whole;
too it seems can only be specified with crate granularity.
Anyone got a solution that doesn’t involve splitting the crate?