rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.56k stars 2.38k forks source link

Consider renaming `debug` to `generate-symbols` in profiles #2373

Open matklad opened 8 years ago

matklad commented 8 years ago

In profiles, one can use

debug = true # Controls whether the compiler passes -g

The name debug is confounding (at least for me):

  1. It says nothing about "symbols",
  2. It implies "slower code", which is false,
  3. It can be confused with "debug-assertions".

Obviously we can't just rename debug to generate-symbols, but we can add an alias and update docs.

steveklabnik commented 8 years ago

This is one of those "history is weird" things. -g is short for "generate debug symbols", and so gets called the "debug flag" by people.

We've changed names of things that are historically important before, so it's not the end of the world, but that's some context at least.

matklad commented 8 years ago

Yeah, OIBIT happen :)

alexcrichton commented 8 years ago

The term "debug" here was generally meant to encompass a number of options for debugging, for example right now it implies debuginfo and debug-assertions. We may want to add more options over time, but each individual option should also have its own key for tuning (I think debuginfo is missing one right now)

The documentation may need to be updated...

matklad commented 8 years ago

it implies debuginfo and debug-assertions.

Hm, not sure. At least this

[profile.release]
debug = true
fn main() {
    debug_assert!(false);
    println!("Hello, world!");
}

runs fine in --release

matklad commented 8 years ago

Yep, and "Controls whether the compiler passes -g" comes from the docs

matklad commented 8 years ago

Some context: https://github.com/rust-lang/cargo/pull/1444#issuecomment-85267563

matklad commented 8 years ago

Ok, quick grep reveals that debug in TomlProfile is used only to set debuginfo in Profile.

The debuginfo is itself used only for two things:

  1. Passing -g to rustc
  2. Passing DEBUG env variable to the build script.

At least gcc crate ignores "DEBUG" env var, and uses "PROFILE" for deciding on -g

alexcrichton commented 8 years ago

Hm maybe that was just the intention and it never got implemented... I thought it was implemented?

alexcrichton commented 8 years ago

Either way though I think that a more appropriate name for "pass the -g flag" would be "debuginfo".

luser commented 4 years ago

Commenting on this extremely old issue to say that we had exactly this same confusion with Firefox builds a long time ago so we added an --enable-debug-symbols option to configure and made it so --enable-debug (which also enabled extra debug assertions) implied --enable-debug-symbols.

ghost commented 4 years ago

+1. This confused me for quite a while. I thought flamegraph-rs wanted me to somehow make the release builds be unoptimized.