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

rustc_codegen_llvm: Give each codegen unit a unique DWARF name on all platforms, not just Apple ones. #92024

Merged
merged 1 commit into from
Dec 18, 2021

Conversation

pcwalton
Copy link
Contributor

To avoid breaking split DWARF, we need to ensure that each codegen unit has a
unique DW_AT_name. This is because there's a remote chance that different
codegen units for the same module will have entirely identical DWARF entries
for the purpose of the DWO ID, which would violate Appendix F ("Split Dwarf
Object Files") of the DWARF 5 specification. LLVM uses the algorithm specified
in section 7.32 "Type Signature Computation" to compute the DWO ID, which does
not include any fields that would distinguish compilation units. So we must
embed the codegen unit name into the DW_AT_name.

Closes #88521.

platforms, not just Apple ones.

To avoid breaking split DWARF, we need to ensure that each codegen unit has a
unique `DW_AT_name`. This is because there's a remote chance that different
codegen units for the same module will have entirely identical DWARF entries
for the purpose of the DWO ID, which would violate Appendix F ("Split Dwarf
Object Files") of the DWARF 5 specification. LLVM uses the algorithm specified
in section 7.32 "Type Signature Computation" to compute the DWO ID, which does
not include any fields that would distinguish compilation units. So we must
embed the codegen unit name into the `DW_AT_name`.

Closes rust-lang#88521.
@pcwalton pcwalton added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. labels Dec 17, 2021
@pcwalton pcwalton requested a review from nagisa December 17, 2021 04:41
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 17, 2021
@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 17, 2021
@pcwalton
Copy link
Contributor Author

pcwalton commented Dec 17, 2021

Note that this only causes a problem in practice if an external (non-rustc) linker is used, because rustc contains some logic to merge DWARF compilation unit entries that has the side effect of working around this bug. That logic, however, is itself a workaround for some other LLVM bugs, so I think it's more appropriate to work around the problem here in rustc instead of adding Rust-specific logic to lld.

@petrochenkov
Copy link
Contributor

r? @davidtwco

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this, I hadn't noticed #88521 but this explains the issue I ran into when trying to bootstrap rustc with Split DWARF (#89819 (comment)).

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Dec 17, 2021

📌 Commit c41fd76 has been approved by davidtwco

@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 Dec 17, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 17, 2021
…davidtwco

rustc_codegen_llvm: Give each codegen unit a unique DWARF name on all platforms, not just Apple ones.

To avoid breaking split DWARF, we need to ensure that each codegen unit has a
unique `DW_AT_name`. This is because there's a remote chance that different
codegen units for the same module will have entirely identical DWARF entries
for the purpose of the DWO ID, which would violate Appendix F ("Split Dwarf
Object Files") of the DWARF 5 specification. LLVM uses the algorithm specified
in section 7.32 "Type Signature Computation" to compute the DWO ID, which does
not include any fields that would distinguish compilation units. So we must
embed the codegen unit name into the `DW_AT_name`.

Closes rust-lang#88521.
This was referenced Dec 17, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 18, 2021
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#91566 (Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF)
 - rust-lang#91926 (Remove `in_band_lifetimes` from `rustc_metadata`)
 - rust-lang#91931 (Remove `in_band_lifetimes` from `rustc_codegen_llvm`)
 - rust-lang#92024 (rustc_codegen_llvm: Give each codegen unit a unique DWARF name on all platforms, not just Apple ones.)
 - rust-lang#92037 (Use a const ParamEnv when in default_method_body_is_const)
 - rust-lang#92047 (Set `RUST_BACKTRACE=0` when running location-detail tests)
 - rust-lang#92050 (Add a space and 2 grave accents )

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 53a95ea into rust-lang:master Dec 18, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DWARF] Crate Debug Info incomplete?
6 participants