cargo icon indicating copy to clipboard operation
cargo copied to clipboard

cargo reports a warning: `panic` setting is ignored for `bench` profile. When the value it is not ignored.

Open zeroflaw opened this issue 9 months ago • 2 comments

Problem

cargo bench fails to compile when using build-std, however including 'panic = "unwind"' in Cargo.toml '[profile.bench]' fixes the issue. This causes cargo to warn about the setting being ignored, when it's clearly doing something.

Steps

versions:

rustc 1.80.0-nightly (87293c958 2024-05-08)
cargo 1.80.0-nightly (0ca60e940 2024-05-08)

~/.cargo/config.toml

[build]
rustflags = [
  "-C", "panic=abort",
  "-Z", "panic-in-drop=abort",
  "-Z", "panic_abort_tests",
]
target = "x86_64-unknown-linux-gnu"

[unstable]
build-std = ["core,alloc,std,panic_abort"]
build-std-features = []

/project/Cargo.toml

[workspace]
resolver = "2"
members = [ 
#snip
]

[profile.bench]
lto = true
codegen-units = 1
panic = "unwind"

[profile.release]
lto = true
codegen-units = 1
panic = "abort"

bench.rs

#![feature(test)]
extern crate test;

#[bench]
fn bench_a_thing(b: &mut test::Bencher) {
//snip
}

cargo bench without 'panic = "unwind"' in Cargo.toml '[profile.bench]'

error: the `#[alloc_error_handler]` in std conflicts with allocation error handler in: std

error[E0152]: duplicate lang item in crate `std` (which `test` depends on): `panic_impl`.

cargo bench with 'panic = "unwind"' in Cargo.toml '[profile.bench]'

warning: /project/Cargo.toml: `panic` setting is ignored for `bench` profile

bench run successful.

Possible Solution(s)

suppress / remove the warning, panic setting is ignored for bench profile

Notes

No response

Version

No response

zeroflaw avatar May 09 '24 20:05 zeroflaw