#230 RFE: build rust libraries in debug mode and only build binaries in release mode
Opened a year ago by decathorpe. Modified a month ago

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.


Metadata Update from @decathorpe:
- Issue set to the milestone: v24.1 (was: 24)

a year ago

Metadata Update from @decathorpe:
- Issue set to the milestone: v24.2 (was: v24.1)

a year ago

Metadata Update from @decathorpe:
- Issue set to the milestone: v24.4 (was: v24.2)

a year ago

Metadata Update from @decathorpe:
- Issue set to the milestone: v24.5 (was: v24.4)

8 months ago

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.

Metadata Update from @decathorpe:
- Issue set to the milestone: None (was: v24.5)

6 months ago

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.

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

2 months ago

Thinking about this some more, the easiest way to handle this might be:

  • move cargo build, cargo test into subshells similar to cargo_install
  • unset RUSTFLAGS in those subshells
  • pass --profile rpm if only if debug_package is not set to %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.

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.

Login to comment on this ticket.

Metadata