We don't ship any compiled artifacts from library-only crates. Doing optimized builds there is wasteful, often triggers crashes in Rustc / LLVM, and hides some test failures (no debug assertions, no overflow checks, etc.).
It should be possible to check %cargo_is_bin() and only include --release in build flags if that macro returns 1.
%cargo_is_bin()
--release
Metadata Update from @decathorpe: - Issue set to the milestone: v24.1 (was: 24)
Metadata Update from @decathorpe: - Issue set to the milestone: v24.2 (was: v24.1)
Metadata Update from @decathorpe: - Issue set to the milestone: v24.4 (was: v24.2)
Metadata Update from @decathorpe: - Issue set to the milestone: v24.5 (was: v24.4)
Since cargo macros now already use a custom rpm profile, maybe there could be another custom profile (rpm-debug, bikeshedding about the name appreciated), which is used instead of the rpm profile if the package contains no binary deliverables? Setting the --profile flag based on the output of %cargo_is_bin() should be possible, I think.
rpm
rpm-debug
--profile
Metadata Update from @decathorpe: - Issue set to the milestone: None (was: v24.5)
This will need to be implemented in rust-packaging.
Option 1 would be to modify the in the %cargo_prep macro to generate a.cargo/config file that defines both a "release" and a "debug" profile, and then modify %cargo_build / %cargo_install / %cargo_test macros, where the --profile can then be set accordingly.
%cargo_prep
.cargo/config
%cargo_build
%cargo_install
%cargo_test
Option 2 would be to just modify the %cargo_prep macro and adjust the generated .cargo/config file based on the contents of the current crate (i.e. generate a profile close to "debug" mode if there are no binary targets in the crate).
Keeping this ticket open for tracking purposes, even if the correct project to file this would have been https://pagure.io/fedora-rust/rust-packaging.
Metadata Update from @decathorpe: - Issue set to the milestone: v27.0
Thinking about this some more, the easiest way to handle this might be:
cargo build
cargo test
cargo_install
--profile rpm
debug_package
%nil
Only packages for library-only Rust crates should have %global debug_package %nil, so this is the easiest condition to check for ... and we don't need RUSTFLAGS defined, because the --profile rpm argument for cargo already sets the same options.
%global debug_package %nil
PR that implements the idea in the previous comment: https://pagure.io/fedora-rust/rust-packaging/pull-request/28
This seems to work as expected.
A disadvantage is that testing in release mode can help reveal issues in unsafe code that don’t have practical consequences until stronger optimizations are applied, e.g. https://github.com/milesgranger/blosc2-rs/issues/19.
Ignoring the time/CPU difference, this is probably still outweighed by “Doing optimized builds there […] hides some test failures (no debug assertions, no overflow checks, etc.).”
Metadata Update from @decathorpe: - Issue tagged with: feature
Marking as stalled and removing from the v27.0 milestone.
This will require bigger changes to the RPM macro side than originally anticipated, and those are not planned before the rust2rpm v27 release.
Metadata Update from @decathorpe: - Issue set to the milestone: None (was: v27.0) - Issue tagged with: stalled
Log in to comment on this ticket.