-
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
Don't distinguish Debuginfo::None
and Debuginfo::Explicit(None)
#12205
Conversation
Previously, `Debuginfo::None` meant "don't pass -C debuginfo" and `Explicit(None)` meant "-C debuginfo=0", which occasionally led to caching bugs where cargo would sometimes pass `-C debuginfo=0` and sometimes not. There are no such bugs currently that we know of, but representing them the same within cargo avoids the possibility of the bug popping up again in the future. I tested the `with_stderr_does_not_contain_tests` with this diff to ensure they did not pass: ```diff diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 55ec17182..c186dd00a 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -1073,9 +1073,7 @@ fn build_base_args( let debuginfo = debuginfo.into_inner(); // Shorten the number of arguments if possible. - if debuginfo != TomlDebugInfo::None { cmd.arg("-C").arg(format!("debuginfo={}", debuginfo)); - } cmd.args(unit.pkg.manifest().lint_rustflags()); if !rustflags.is_empty() { ```
c35fdbf
to
e2eacc6
Compare
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.
Beautiful!!! Thank you!
Only one minor doc comment issue left.
BTW I found split-debuginfo
is also redundant when debuginfo != TomlDebugInfo::None
. Just FYI. No need to change.
cargo/src/cargo/core/compiler/mod.rs
Lines 1055 to 1064 in e2eacc6
if let Some(split) = split_debuginfo { | |
if cx | |
.bcx | |
.target_data | |
.info(unit.kind) | |
.supports_debuginfo_split(split) | |
{ | |
cmd.arg("-C").arg(format!("split-debuginfo={}", split)); | |
} | |
} |
Co-authored-by: Weihang Lo <weihanglo@users.noreply.github.com>
Do we test for / does this break setting debug info via RUSTFLAGS? That use case is probably not well supported, but it's sometimes more convenient than alternatives (e.g., because of target-dependent debuginfo which I'm not sure is otherwise file configuration placeable). |
I would be extremely surprised if that worked before this PR; the reason I made #11958 originally is I couldn't figure out how to do it through RUSTFLAGS in bootstrap. That said, this passes |
Thanks for calling out!
cargo/src/cargo/core/compiler/mod.rs Line 1075 in c9b89c6
cargo/src/cargo/core/compiler/mod.rs Line 322 in c9b89c6
|
Thanks! @bors r+ |
☀️ Test successful - checks-actions |
This was an overlook in rust-lang#12205
Update cargo 14 commits in f7b95e31642e09c2b6eabb18ed75007dda6677a0..b0fa79679e717cd077b7fc0fa4166f47107f1ba9 2023-05-30 19:25:02 +0000 to 2023-06-03 14:19:48 +0000 - Emit error when users try to use a toolchain via the `add` or `install` command (rust-lang/cargo#12226) - Support "default" option for `build.jobs` (rust-lang/cargo#12222) - Fix typo in changelog (rust-lang/cargo#12227) - chore: Sort `-Z` flags match statement (rust-lang/cargo#12223) - Update curl-sys (rust-lang/cargo#12218) - Bump to 0.73.0; update changelog (rust-lang/cargo#12219) - refactor: housekeeping for 1.70.0 (rust-lang/cargo#12217) - nit: fix typo in changelog for 1.70 (rust-lang/cargo#12215) - Remove a noop `.clone` (rust-lang/cargo#12213) - refactor: compiler invocations (rust-lang/cargo#12211) - cargo clean: use `remove_dir_all` (rust-lang/cargo#11442) - Add a small note about indexes ignoring SemVer build metadata. (rust-lang/cargo#12206) - Revert "chore: detect the channel a PR wants to merge into" (rust-lang/cargo#12204) - Don't distinguish `Debuginfo::None` and `Debuginfo::Explicit(None)` (rust-lang/cargo#12205) r? `@ghost`
Update cargo 14 commits in f7b95e31642e09c2b6eabb18ed75007dda6677a0..b0fa79679e717cd077b7fc0fa4166f47107f1ba9 2023-05-30 19:25:02 +0000 to 2023-06-03 14:19:48 +0000 - Emit error when users try to use a toolchain via the `add` or `install` command (rust-lang/cargo#12226) - Support "default" option for `build.jobs` (rust-lang/cargo#12222) - Fix typo in changelog (rust-lang/cargo#12227) - chore: Sort `-Z` flags match statement (rust-lang/cargo#12223) - Update curl-sys (rust-lang/cargo#12218) - Bump to 0.73.0; update changelog (rust-lang/cargo#12219) - refactor: housekeeping for 1.70.0 (rust-lang/cargo#12217) - nit: fix typo in changelog for 1.70 (rust-lang/cargo#12215) - Remove a noop `.clone` (rust-lang/cargo#12213) - refactor: compiler invocations (rust-lang/cargo#12211) - cargo clean: use `remove_dir_all` (rust-lang/cargo#11442) - Add a small note about indexes ignoring SemVer build metadata. (rust-lang/cargo#12206) - Revert "chore: detect the channel a PR wants to merge into" (rust-lang/cargo#12204) - Don't distinguish `Debuginfo::None` and `Debuginfo::Explicit(None)` (rust-lang/cargo#12205) r? `@ghost`
Previously,
Debuginfo::None
meant "don't pass -C debuginfo" andExplicit(None)
meant "-C debuginfo=0", which occasionally led to caching bugs where cargo would sometimes pass-C debuginfo=0
and sometimes not. There are no such bugs currently that we know of, but representing them the same within cargo avoids the possibility of the bug popping up again in the future.I tested the
with_stderr_does_not_contain
tests with this diff to ensure they did not pass:What does this PR try to resolve?
This reduces the likelihood of a latent caching bug. See #12163 (comment) for details.
How should we test and review this PR?
Run
cargo test
. To verify thewith_stderr_does_not_contain
tests are actually doing something, apply the diff in the description above and reruncargo test
. You should see 5 failures in theprofiles
andprofile_targets
modules.Additional information
The only subtle bit of logic this changes is
cargo/src/cargo/core/profiles.rs
Lines 442 to 452 in c35fdbf
profile.debuginfo.to_option()
would be None is when it was set toDebuginfo::None
. In that case today, we'll now set it toDeferred(None)
. The only time that can be modified is incargo/src/cargo/ops/cargo_compile/mod.rs
Lines 661 to 698 in ae252b5
Resolved(None)
regardless of whether the unit graph has a matching unit in the runtime graph or not.I think there are existing tests for this behavior but I'm not sure.
r? @weihanglo