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

Make cargo aware of dwp files. #11572

Merged
merged 2 commits into from
Jan 30, 2023
Merged

Make cargo aware of dwp files. #11572

merged 2 commits into from
Jan 30, 2023

Conversation

khuey
Copy link
Contributor

@khuey khuey commented Jan 13, 2023

When using -Csplit-debuginfo=packed on Linux, rustc will produce a dwp file. Unlike the dwo files, whose paths are embedded into the binary, there's no information in the binary to help a debugger locate a dwp file. By convention, the dwp file for <EXE> is given the name <EXE>.dwp and placed next to <EXE>.

When cargo hardlinks the executable file rustc put in target/debug/deps into target/debug, it also needs to hardlink the dwp file along with it. Failing to do this prevents the debugger from finding the dwp file when the binary is executed from target/debug, as there's no way for the debugger to know to look in the deps subdirectory.

The split_debuginfo option is passed down into file_types to make this possible. For cargo clean manual handling is added to match the other split_debuginfo files. bin_link_for_target also passes in None because it won't care about the dwp file.

@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @epage (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 Jan 13, 2023
@khuey
Copy link
Contributor Author

khuey commented Jan 13, 2023

cc @davidtwco

@khuey
Copy link
Contributor Author

khuey commented Jan 13, 2023

CI seems broken.

@weihanglo
Copy link
Member

Thank you! Looks like a duplicate of #11384? I would probably ping them to see if they want to proceed. There is also a discussion regarding artifact name conflict on Windows which is worth considering.

@weihanglo
Copy link
Member

r? @weihanglo

@khuey
Copy link
Contributor Author

khuey commented Jan 13, 2023

Thanks for the pointer to the other PR. I hadn't seen that.

The mingw issue they ran across is actually a rustc bug: rust-lang/rust#106811. .dwp should be added to the filename; it should not replace the existing extension. On Linux this isn't noticed on regular binaries but it is visible if you build a dylib. I've fixed the cargo side of that in the updated commit here.

I've also added a test along the lines you suggested in the other PR. It would be good to test the dylib behavior too but I don't know how cargo handles varying rustc versions for tests. Any test would need a version of rustc with the rustc PR above merged to pass.

I think the main difference between the PRs at this point is whether the split_debuginfo value is passed into file_types (and thus whether the DWP entry is emitted only when relevant or all the time).

@khuey
Copy link
Contributor Author

khuey commented Jan 13, 2023

And the value of should_replace_hyphens has to match the value the binary itself had. Setting it to false unconditionally as in the other PR is wrong.

@ehuss
Copy link
Contributor

ehuss commented Jan 13, 2023

I think the main difference between the PRs at this point is whether the split_debuginfo value is passed into file_types (and thus whether the DWP entry is emitted only when relevant or all the time).

So far cargo has generated the FileType list with all potential files that rustc might generate, and doesn't necessarily differentiate based on anything like profile settings. It is generally safe to list extra files since cargo will ignore them if rustc didn't generate them. I can't offhand think of a particular problem of differentiating, but by adding it here for just dwp that makes the code inconsistent with other platforms.

@khuey
Copy link
Contributor Author

khuey commented Jan 14, 2023

Alright, done.

When using -Csplit-debuginfo=packed on Linux, rustc will produce a dwp file.
Unlike the dwo files, whose paths are embedded into the binary, there's no
information in the binary to help a debugger locate a dwp file. By convention,
the dwp file for <EXE> is given the name <EXE>.dwp and placed next to <EXE>.

When cargo hardlinks the executable file rustc put in target/debug/deps into
target/debug, it also needs to hardlink the dwp file along with it. Failing to
do this prevents the debugger from finding the dwp file when the binary is
executed from target/debug, as there's no way for the debugger to know to look
in the deps subdirectory.
@khuey
Copy link
Contributor Author

khuey commented Jan 15, 2023

Yay the tests finally pass.

@khuey
Copy link
Contributor Author

khuey commented Jan 16, 2023

Also even once you are satisfied with this you probably shouldn't merge it before rust-lang/rust#106811 is merged.

@weihanglo
Copy link
Member

Also even once you are satisfied with this you probably shouldn't merge it before rust-lang/rust#106811 is merged.

Fair enough. Let's label it as blocked until that PR gets merged.

@weihanglo weihanglo added S-blocked and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 16, 2023
@Gankra
Copy link
Contributor

Gankra commented Jan 16, 2023

Oh, thanks so much for picking this up and doing it right!

@khuey
Copy link
Contributor Author

khuey commented Jan 27, 2023

The rustc PRs this depends on have been merged.

@khuey khuey requested a review from weihanglo January 30, 2023 04:44
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.

Looks good. Thanks!

@weihanglo
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Jan 30, 2023

📌 Commit a393267 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-blocked labels Jan 30, 2023
@bors
Copy link
Collaborator

bors commented Jan 30, 2023

⌛ Testing commit a393267 with merge 99b1369...

@bors
Copy link
Collaborator

bors commented Jan 30, 2023

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

@bors bors merged commit 99b1369 into rust-lang:master Jan 30, 2023
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 added this to the 1.69.0 milestone Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

None yet

7 participants