How to use panic = abort with external dependencies?

For single-box projects, adding these lines to Cargo.toml works as expected.

 [profile.release] panic = "abort" 

Then create a project:

 cargo build --release 

However, in a project that indirectly used dependencies, I get an error message.

  Compiling c_vec v1.0.12 error: the linked panic runtime `panic_unwind` is not compiled with this crate panic strategy `abort` error: aborting due to previous error Build failed, waiting for other jobs to finish... error: Could not compile `c_vec`. 

The c_vec box is an indirectly used dependency.

How to use panic=abort in a project with multiple drawers without conflicts?


Details that they matter:

  • Rustc 1.12.0
  • Library with the question: lodepng-rust
  • Linux 64bit
+7
rust rust-cargo
source share
1 answer

It seems because c_vec indicates dylib as one of its library types.

I filed this issue on Github here: https://github.com/rust-lang/cargo/issues/2738

And I received a response from one of the developers:

ah, unfortunately, a bad error message, but this is due to crate-type = ["dylib", "rlib"] in the c_vec box. This causes Cargo to go through -C preference-dynamics, which refers to the dylib that we send, which is compiled against panic_unwind, which means the interrupt mode is really invalid (this error comes from the compiler).

A fix here would be to remove the "dylib" from the c_vec box.

Of course you will need to break your own lodepng and c_vec to take care of this.

+3
source share

All Articles