-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow named debuginfo options in Cargo.toml #11958
Conversation
r? @weihanglo (rustbot has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
I don't know anywhere (currently) that |
Rustc supports these since rust-lang/rust#109808. It's technically possible to set a named debuginfo level through `RUSTFLAGS`, but in practice cargo always passes its own opinion of what the debuginfo level is, so allow it to be configured through cargo too.
Thanks for the feedback! I ended up redoing the main data structure from an arbitrary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the docs for debug
in profile?
"none" => TomlDebugInfo::None, | ||
"limited" => TomlDebugInfo::Limited, | ||
"full" => TomlDebugInfo::Full, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this PR is about adding "line-tables-only"
and "line-directives-only"
. If this PR is trying to get cargo
to match rustc
, do you mind updating the PR description with the rational for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the PR description. The main reason is that I want to change 1
to mean line-tables-only
in the next edition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened an MCP for that change: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/2024.3A.20Decrease.20debuginfo.20generated.20by.20.20.60-.E2.80.A6.20compiler-team.23613. I think allowing these aliases won't be too much of a maintenance burden for cargo even if it ends up not happening, though.
- Update the documentation and doc-comments - Improve the error message for parsing Cargo.toml
Just a heads up, I will be bringing this up in the next Cargo team meeting because I am unsure of how stabilization will look. If we were to put this behind a nightly flag, it would mean this is stable in |
This was discussed in the recent Cargo team meeting, and there were no particular objections to instant stabilization since it is already stabilized in |
I've pushed some more tests. @Muscraft can you clarify what you're looking for in the documentation? Right now this matches the documentation for rustc, is there something specific you're looking for? If it helps, here's an example backtrace with each of the new options, compared to none (missing line numbers, missing frames)
line-directives-only (same as none)
line-tables-only (missing module qualifiers for some functions)
limited
but I'm not sure how to condense that into a short sentence. The backtraces at levels lower than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jyn514 and I discussed this and concluded that Cargo's docs should be kept relatively simple and link to Rust's docs on debuginfo
if more information is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good!
Thanks! @bors r+ |
Would it be possible to add some tests that actually use the new options? Since it isn't stable on rustc, yet, they will need to be marked with |
☀️ Test successful - checks-actions |
Update cargo 17 commits in de80432f04da61d98dcbbc1572598071718ccfd2..9e586fbd8b931494067144623b76c37d213b1ab6 2023-04-21 13:18:32 +0000 to 2023-04-25 22:09:11 +0000 - Update home dependency (rust-lang/cargo#12037) - Warn instead of error in `cargo package` on empty `readme` or `license-file` in manifest (rust-lang/cargo#12036) - Clarify documentation around test target setting. (rust-lang/cargo#12032) - fix: apply `[env]` to target info discovery rustc (rust-lang/cargo#12029) - CI: ensure intra links for all members are checked (rust-lang/cargo#12025) - chore: make credential dependencies platform-specific (rust-lang/cargo#12027) - CI: use `-p` to specify workspace members instead of `--manifest-path` (rust-lang/cargo#12024) - ci: requires `test_gitoxide` and `lockfile` for both bors success and failure (rust-lang/cargo#12026) - Update windows-sys (rust-lang/cargo#12021) - Bump libc to 0.2.142 (rust-lang/cargo#12014) - Update openssl-src to 111.25.3+1.1.1t (rust-lang/cargo#12005) - Improve error message for empty dep (rust-lang/cargo#12001) - Remove wrong url in benchsuite manifest. (rust-lang/cargo#12020) - Bump versions of local crates (rust-lang/cargo#12019) - Add the Win32_System_Console feature since it is used (rust-lang/cargo#12016) - Update outdated crates.io URLs in publishing guide (rust-lang/cargo#12018) - Allow named debuginfo options in Cargo.toml (rust-lang/cargo#11958) r? `@ghost`
Test that the new `debuginfo` options match between cargo and rustc As requested in #11958 (comment). r? `@ehuss`
Update docs for artifact JSON debuginfo levels. String-based debuginfo levels were added in #11958, but the documentation wasn't updated to reflect that.
What does this PR try to resolve?
Rustc supports these since rust-lang/rust#109808. It's technically possible to set a named debuginfo level through
RUSTFLAGS
, but in practice cargo always passes its own opinion of what the debuginfo level is, so allow it to be configured through cargo too so the options don't conflict.Note that this also adds support for
"none"
,"limited"
, and"full"
as aliases for 0, 1, and 2 respectively. The motivation is not just to match rustc, but also to make it easier for us to change the default for1
over an edition to mean"line-tables-only"
instead of"limited"
. If we allowlimited
as an alias for1
, people will be able to use it before and after the change in defaults to mean the same thing; if we disallow it and only allow it in the new edition, it will be impossible to have the same code work with both new and old versions of cargo.How should we test and review this PR?
All modified tests are normal tests that can be run with
cargo test
. You can also build cargo from source and verify thatCARGO_PROFILE_DEV_DEBUG=line-tables-only cargo build
on a hello world project correctly passes-C debuginfo=line-tables-only
through to rustc.I recommend viewing this with whitespace changes hidden.
Additional information
Enabling these flags in cargo is required before bootstrap can start passing them through to rustc (which I'd like to do so we can reduce the size of the generated artifacts: rust-lang/rust#104968 (comment)).