Skip to content

Profile setting for -Zfmt-debug #15439

Open
@ronnychevalier

Description

@ronnychevalier

Problem

rustc supports the -Zfmt-debug option. When enabled, #[derive(Debug)] and {:?} generate a no-op implementation. This can be useful, for instance, to further strip debug symbols and debug code from a binary. See the implementation PR for a more complete description.

Currently, to use this feature, one needs to add the option manually to RUSTFLAGS when using cargo build.

Proposed Solution

This feature could be available in cargo as a new profile setting called debug-format. It would make it easier to use and it would allow users to define a different value depending on the profile. It would look like this:

# Cargo.toml
cargo-features = ["debug-format"] # or use the unstable flag: `cargo build -Zdebug-format`

[package]
# ...

[profile.release]
debug-format = "none"

The possible values would be the same as the one exposed by rustc: full, none, and shallow.

It could also be possible to have by default the value none for the release profile, and full for the dev profile.

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-profilesArea: profilesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions