Skip to content
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

Fix split-debuginfo support detection #11347

Merged
merged 2 commits into from
Jan 26, 2023

Conversation

kamirr
Copy link
Contributor

@kamirr kamirr commented Nov 6, 2022

What does this PR try to resolve?

cargo assumed that if -Csplit-debuginfo=packed worked, all values would be correct. This however is not the case -- as of Rust 1.65.0, rustc supports packed, but not unpacked or off on Windows. Because of this, having split-debuginfo="unpacked" on Windows has caused builds to fail, as cargo assumed that the option is fine (split-debuginfo=packed worked), but rustc then failed when being passed -Csplit-debuginfo=unpacked.

How should we test and review this PR?

Consider an empty project with the following change to Cargo.toml:

[profile.dev]
split-debuginfo="unpacked"

cargo +1.64.0 build will work, but cargo +1.65.0 build will fail with the following error message:

PS C:\REDACTED> cargo build
   Compiling tmp v0.1.0 (C:\REDACTED)
error: `-Csplit-debuginfo=unpacked` is unstable on this platform

error: could not compile `tmp` due to previous error

With this patch and 1.65.0 rustc, cargo will ignore all split-debuginfo settings, but with rust-lang/rust#104104 rustc (approved, awaiting merge), it will properly detect supported values for split-debuginfo and only ignore those that are unsupported.

@rustbot
Copy link
Collaborator

rustbot commented Nov 6, 2022

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon.

Please see the contribution instructions for more information.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 6, 2022
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call on this! Thank you for the pull request.

src/cargo/core/compiler/build_context/target_info.rs Outdated Show resolved Hide resolved
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 8, 2022
Add split-debuginfo print option

This option prints all supported values for `-Csplit-debuginfo=..`, i.e. only stable ones on stable/beta and all of them on nightly/dev.

Motivated by 1.65.0 regression causing builds with the following entry in `Cargo.toml` to fail on Windows:
```toml
[profile.dev]
split-debuginfo = "unpacked"
```

See rust-lang/cargo#11347 for details.

This will lead to closing rust-lang#103976.
cargo assumed that if -Csplit-debuginfo=packed worked, all values would
be correct. This however is not the case -- as of Rust 1.65.0, rustc
supports packed, but not unpacked or off on Windows. Because of this,
having split-debuginfo="unpacked" on Windows has caused builds to fail,
as cargo assumed that the option is fine (split-debuginfo=packed
worked), but rustc then failed when being passed
-Csplit-debuginfo=unpacked.

This patch invokes rustc with the --print=split-debuginfo to query
supported values and ignores the Cargo.toml entry if not supported.
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to see your patch for rustc going to be landed!

Two possible enhancements could be done in this pull request:

  • I found there is no test around this feature. How about writing some basics test validating we're passing correct -Csplit-debuginfo to rustc? Maybe we could exclude Windows from these tests at this time.
  • Should we add a warning if given split-debuginfo option is not supported? We can spin off this to a separate issue though. Might be too noisy. Leave it.

src/cargo/core/compiler/mod.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/mod.rs Outdated Show resolved Hide resolved
src/cargo/core/compiler/mod.rs Outdated Show resolved Hide resolved
@kamirr
Copy link
Contributor Author

kamirr commented Nov 8, 2022

macOS tests fail due to missing .dSYM artifacts, this is expected as explained in the top-level comment (we ignore split-debuginfo with stable rustc, but will handle it correctly on master after rust-lang/rust#104143 is merged). Does that require any action from my side?

I found there is no test around this feature. How about writing some basics test validating we're passing correct -Csplit-debuginfo to rustc? Maybe we could exclude Windows from these tests at this time.

While I can write such tests, they won't pass now anyway due to reasons outlined above. What do you think about it?

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 8, 2022
Add split-debuginfo print option

This option prints all supported values for `-Csplit-debuginfo=..`, i.e. only stable ones on stable/beta and all of them on nightly/dev.

Motivated by 1.65.0 regression causing builds with the following entry in `Cargo.toml` to fail on Windows:
```toml
[profile.dev]
split-debuginfo = "unpacked"
```

See rust-lang/cargo#11347 for details.

This will lead to closing rust-lang#103976.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 8, 2022
Add split-debuginfo print option

This option prints all supported values for `-Csplit-debuginfo=..`, i.e. only stable ones on stable/beta and all of them on nightly/dev.

Motivated by 1.65.0 regression causing builds with the following entry in `Cargo.toml` to fail on Windows:
```toml
[profile.dev]
split-debuginfo = "unpacked"
```

See rust-lang/cargo#11347 for details.

This will lead to closing rust-lang#103976.
@kamirr kamirr requested a review from weihanglo November 8, 2022 14:57
@weihanglo
Copy link
Member

Does that require any action from my side?

No. Not really. I guess we are required to wait for your rustc patch hitting stable (presumably 1.67). Only after that this pull request can be merged.

@weihanglo weihanglo added S-blocked and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 8, 2022
Manishearth added a commit to Manishearth/rust that referenced this pull request Nov 8, 2022
Add split-debuginfo print option

This option prints all supported values for `-Csplit-debuginfo=..`, i.e. only stable ones on stable/beta and all of them on nightly/dev.

Motivated by 1.65.0 regression causing builds with the following entry in `Cargo.toml` to fail on Windows:
```toml
[profile.dev]
split-debuginfo = "unpacked"
```

See rust-lang/cargo#11347 for details.

This will lead to closing rust-lang#103976.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 8, 2022
Add split-debuginfo print option

This option prints all supported values for `-Csplit-debuginfo=..`, i.e. only stable ones on stable/beta and all of them on nightly/dev.

Motivated by 1.65.0 regression causing builds with the following entry in `Cargo.toml` to fail on Windows:
```toml
[profile.dev]
split-debuginfo = "unpacked"
```

See rust-lang/cargo#11347 for details.

This will lead to closing rust-lang#103976.
@kamirr
Copy link
Contributor Author

kamirr commented Nov 9, 2022

The patch was merged, so it's indeed on track to 1.67. One question about cargo release cycle -- if we get this PR merged after 1.67 is released, will that mean that the patched cargo will be released in 1.68, or later?

@weihanglo
Copy link
Member

The patch was merged, so it's indeed on track to 1.67. One question about cargo release cycle -- if we get this PR merged after 1.67 is released, will that mean that the patched cargo will be released in 1.68, or later?

Cargo, and several other official components, follow Rust's train release model. The release schedule is found here. That is, if we get this merged after 1.67 is released, it should hit stable channel on 1.69.

@ehuss
Copy link
Contributor

ehuss commented Dec 2, 2022

Just to be clear, will this be blocked until after Jan 26?

It's a bit unfortunate to still incur a second rustc invocation. I wonder if some day in the future we should consider adding some kind of query command to rustc that will print a json blob with all the information we need once.

@weihanglo
Copy link
Member

Just to be clear, will this be blocked until after Jan 26?

It's a bit unfortunate to still incur a second rustc invocation. I wonder if some day in the future we should consider adding some kind of query command to rustc that will print a json blob with all the information we need once.

I feel like it can be merged into the other with some tricks. But yeah, it is blocked until the change of rustc get stabilized.

@kamirr
Copy link
Contributor Author

kamirr commented Jan 26, 2023

@weihanglo this patch should now work with stable Rust, can you re-run CI?

@weihanglo
Copy link
Member

@bors try

bors added a commit that referenced this pull request Jan 26, 2023
Fix split-debuginfo support detection

### What does this PR try to resolve?
cargo assumed that if `-Csplit-debuginfo=packed` worked, all values would be correct. This however is not the case -- as of Rust 1.65.0, rustc supports `packed`, but not `unpacked` or `off` on Windows. Because of this, having `split-debuginfo="unpacked`" on Windows has caused builds to fail, as cargo assumed that the option is fine (`split-debuginfo=packed` worked), but rustc then failed when being passed `-Csplit-debuginfo=unpacked`.

### How should we test and review this PR?
Consider an empty project with the following change to `Cargo.toml`:
```toml
[profile.dev]
split-debuginfo="unpacked"
```
`cargo +1.64.0 build` will work, but `cargo +1.65.0 build` will fail with the following error message:

```
PS C:\REDACTED> cargo build
   Compiling tmp v0.1.0 (C:\REDACTED)
error: `-Csplit-debuginfo=unpacked` is unstable on this platform

error: could not compile `tmp` due to previous error
```

With this patch and 1.65.0 rustc, cargo will ignore all `split-debuginfo` settings, but with rust-lang/rust#104104 rustc (approved, awaiting merge), it will properly detect supported values for `split-debuginfo` and only ignore those that are unsupported.
@bors
Copy link
Contributor

bors commented Jan 26, 2023

⌛ Trying commit fe95630 with merge 641a4e1...

@bors
Copy link
Contributor

bors commented Jan 26, 2023

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked labels Jan 26, 2023
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This try looks good https://github.com/rust-lang/cargo/actions/runs/4016766934. Thank you for the contribution and long waiting!

@weihanglo
Copy link
Member

@bors r+

BTW, to optimize it a bit, we could explore a way merging multiple rustc calls into one.

@bors
Copy link
Contributor

bors commented Jan 26, 2023

📌 Commit fe95630 has been approved by weihanglo

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 26, 2023
@bors
Copy link
Contributor

bors commented Jan 26, 2023

⌛ Testing commit fe95630 with merge c03cc59...

@bors
Copy link
Contributor

bors commented Jan 26, 2023

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing c03cc59 to master...

@bors bors merged commit c03cc59 into rust-lang:master Jan 26, 2023
@ehuss ehuss added the beta-nominated Nominated to backport to the beta branch. label Jan 28, 2023
weihanglo pushed a commit to weihanglo/cargo that referenced this pull request Jan 29, 2023
…=weihanglo

Fix split-debuginfo support detection

### What does this PR try to resolve?
cargo assumed that if `-Csplit-debuginfo=packed` worked, all values would be correct. This however is not the case -- as of Rust 1.65.0, rustc supports `packed`, but not `unpacked` or `off` on Windows. Because of this, having `split-debuginfo="unpacked`" on Windows has caused builds to fail, as cargo assumed that the option is fine (`split-debuginfo=packed` worked), but rustc then failed when being passed `-Csplit-debuginfo=unpacked`.

### How should we test and review this PR?
Consider an empty project with the following change to `Cargo.toml`:
```toml
[profile.dev]
split-debuginfo="unpacked"
```
`cargo +1.64.0 build` will work, but `cargo +1.65.0 build` will fail with the following error message:

```
PS C:\REDACTED> cargo build
   Compiling tmp v0.1.0 (C:\REDACTED)
error: `-Csplit-debuginfo=unpacked` is unstable on this platform

error: could not compile `tmp` due to previous error
```

With this patch and 1.65.0 rustc, cargo will ignore all `split-debuginfo` settings, but with rust-lang/rust#104104 rustc (approved, awaiting merge), it will properly detect supported values for `split-debuginfo` and only ignore those that are unsupported.
bors added a commit that referenced this pull request Jan 30, 2023
 [beta-1.68] Backport fixes of split-debuginfo detection

Beta backports:

* #11347 — Fix split-debuginfo support detection
* #11633 — Reduce target info rustc query calls

In order to make CI pass, the following PR are also cherry-picked:

* #11619
* #11609
* #11610
bors added a commit that referenced this pull request Jan 30, 2023
 [beta-1.68] Backport fixes of split-debuginfo detection

Beta backports:

* #11347 — Fix split-debuginfo support detection
* #11633 — Reduce target info rustc query calls

In order to make CI pass, the following PR are also cherry-picked:

* #11619
* #11609
* #11610
weihanglo added a commit to weihanglo/rust that referenced this pull request Feb 1, 2023
18 commits in 3c5af6bed9a1a243a693e8e22ee2486bd5b82a6c..e84a7928d93a31f284b497c214a2ece69b4d7719
2023-01-24 15:48:15 +0000 to 2023-01-31 22:18:09 +0000

- chore: Add autolabel for `Command-*` labels (rust-lang/cargo#11664)
- Update cross test instructions for aarch64-apple-darwin (rust-lang/cargo#11663)
- Make cargo install report needed features (rust-lang/cargo#11647)
- docs(contrib): Remove out-of-date process step (rust-lang/cargo#11662)
- Do not error for `auth-required: true` without `-Z sparse-registry` (rust-lang/cargo#11661)
- Warn on commits to non-default branches. (rust-lang/cargo#11655)
- Avoid saving the same future_incompat warning multiple times (rust-lang/cargo#11648)
- Mention current default value in `publish.timeout` docs (rust-lang/cargo#11652)
- Make cargo aware of dwp files. (rust-lang/cargo#11572)
- Reduce target info rustc query calls (rust-lang/cargo#11633)
- Bump to 0.70.0; update changelog (rust-lang/cargo#11640)
- Enable sparse protocol in CI (rust-lang/cargo#11632)
- Fix split-debuginfo support detection (rust-lang/cargo#11347)
- refactor(toml): Move `TomlWorkspaceDependency` out of `TomlDependency` (rust-lang/cargo#11565)
- book: describe how the current resolver sometimes duplicates deps (rust-lang/cargo#11604)
- `cargo add` check `[dependencies]` order without considering the dotted item (rust-lang/cargo#11612)
- Link CoC to  www.rust-lang.org/conduct.html (rust-lang/cargo#11622)
- Add more labels to triagebot (rust-lang/cargo#11621)
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 1, 2023
Update cargo

18 commits in 3c5af6bed9a1a243a693e8e22ee2486bd5b82a6c..e84a7928d93a31f284b497c214a2ece69b4d7719 2023-01-24 15:48:15 +0000 to 2023-01-31 22:18:09 +0000

- chore: Add autolabel for `Command-*` labels (rust-lang/cargo#11664)
- Update cross test instructions for aarch64-apple-darwin (rust-lang/cargo#11663)
- Make cargo install report needed features (rust-lang/cargo#11647)
- docs(contrib): Remove out-of-date process step (rust-lang/cargo#11662)
- Do not error for `auth-required: true` without `-Z sparse-registry` (rust-lang/cargo#11661)
- Warn on commits to non-default branches. (rust-lang/cargo#11655)
- Avoid saving the same future_incompat warning multiple times (rust-lang/cargo#11648)
- Mention current default value in `publish.timeout` docs (rust-lang/cargo#11652)
- Make cargo aware of dwp files. (rust-lang/cargo#11572)
- Reduce target info rustc query calls (rust-lang/cargo#11633)
- Bump to 0.70.0; update changelog (rust-lang/cargo#11640)
- Enable sparse protocol in CI (rust-lang/cargo#11632)
- Fix split-debuginfo support detection (rust-lang/cargo#11347)
- refactor(toml): Move `TomlWorkspaceDependency` out of `TomlDependency` (rust-lang/cargo#11565)
- book: describe how the current resolver sometimes duplicates deps (rust-lang/cargo#11604)
- `cargo add` check `[dependencies]` order without considering the dotted item (rust-lang/cargo#11612)
- Link CoC to  www.rust-lang.org/conduct.html (rust-lang/cargo#11622)
- Add more labels to triagebot (rust-lang/cargo#11621)

r? `@ghost`
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Feb 1, 2023
Update cargo

18 commits in 3c5af6bed9a1a243a693e8e22ee2486bd5b82a6c..e84a7928d93a31f284b497c214a2ece69b4d7719 2023-01-24 15:48:15 +0000 to 2023-01-31 22:18:09 +0000

- chore: Add autolabel for `Command-*` labels (rust-lang/cargo#11664)
- Update cross test instructions for aarch64-apple-darwin (rust-lang/cargo#11663)
- Make cargo install report needed features (rust-lang/cargo#11647)
- docs(contrib): Remove out-of-date process step (rust-lang/cargo#11662)
- Do not error for `auth-required: true` without `-Z sparse-registry` (rust-lang/cargo#11661)
- Warn on commits to non-default branches. (rust-lang/cargo#11655)
- Avoid saving the same future_incompat warning multiple times (rust-lang/cargo#11648)
- Mention current default value in `publish.timeout` docs (rust-lang/cargo#11652)
- Make cargo aware of dwp files. (rust-lang/cargo#11572)
- Reduce target info rustc query calls (rust-lang/cargo#11633)
- Bump to 0.70.0; update changelog (rust-lang/cargo#11640)
- Enable sparse protocol in CI (rust-lang/cargo#11632)
- Fix split-debuginfo support detection (rust-lang/cargo#11347)
- refactor(toml): Move `TomlWorkspaceDependency` out of `TomlDependency` (rust-lang/cargo#11565)
- book: describe how the current resolver sometimes duplicates deps (rust-lang/cargo#11604)
- `cargo add` check `[dependencies]` order without considering the dotted item (rust-lang/cargo#11612)
- Link CoC to  www.rust-lang.org/conduct.html (rust-lang/cargo#11622)
- Add more labels to triagebot (rust-lang/cargo#11621)

r? `@ghost`
@ehuss ehuss modified the milestones: 1.69.0, 1.68.0 Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-nominated Nominated to backport to the beta branch. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants