Skip to content

Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF - #91566

Merged
bors merged 8 commits into
rust-lang:masterfrom
cbeuw:remap-dwo-name
Dec 18, 2021
Merged

Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF#91566
bors merged 8 commits into
rust-lang:masterfrom
cbeuw:remap-dwo-name

Conversation

@cbeuw

@cbeuwcbeuw commented Dec 5, 2021

Copy link
Copy Markdown
Contributor

--remap-path-prefix doesn't apply to paths to .o (in case of packed) or .dwo (in case of unpacked) files in DW_AT_GNU_dwo_name. GCC also has this bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91888

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @oli-obk

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

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 5, 2021
@oli-obk

Copy link
Copy Markdown
Contributor

cc @davidtwco I saw you mention dwp on zulip recently

@davidtwco

davidtwco commented Dec 5, 2021

Copy link
Copy Markdown
Member

I don't have time to do a full review right now (will take a closer look tomorrow), but we could probably do this without breaking packaging:

As rustc invokes the dwarf packaging utility (rather than that being part of a separate build process), we can just always provide the paths to the object files directly rather than just rely on the path computed in the packaging utility from DW_AT_comp_dir and DW_AT_GNU_dwo_name (and for dependencies, we look inside the rlib).

@davidtwco

Copy link
Copy Markdown
Member

r? @davidtwco

@davidtwcodavidtwco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Implementation looks good to me, are there other changes you want to make (the PR is marked WIP)?

@cbeuw

cbeuw commented Dec 6, 2021

Copy link
Copy Markdown
ContributorAuthor

I marked it as draft because I didn't really know if this will work and I wanted to see the Linux CI run results (I'm on Windows so can't really test DWARF properly).

I'll remove WIP and I'm happy to merge as-is once bors is happy too

@cbeuwcbeuw changed the title [WIP] Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARFApply path remapping to DW_AT_GNU_dwo_name when producing split DWARFDec 6, 2021
@cbeuw
cbeuw marked this pull request as ready for review December 6, 2021 14:03
@rust-log-analyzer

This comment has been minimized.

@cbeuw

cbeuw commented Dec 6, 2021

Copy link
Copy Markdown
ContributorAuthor

Turns out my test actually wasn't doing anything and DW_AT_GNU_dwo_name still isn't properly remapped.

This acutally came up before #82074. Will look into it later

@rust-log-analyzer

This comment has been minimized.

@cbeuw

This comment has been minimized.

@apirainoapiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Dec 9, 2021
@cbeuw

This comment has been minimized.

@cbeuw

Copy link
Copy Markdown
ContributorAuthor

I misunderstood how MCOptions.SplitDwarfFile is used in LLVM. It does control what will be emitted into DW_AT_[GNU_]dwo_name, but it can be remapped because it's not used as a real path if pass in a separate a filestream when we create an emit file pass, which we do here:

with_codegen(tm, llmod, config.no_builtins, |cpm| {
write_output_file(
diag_handler,
tm,
cpm,
llmod,
&obj_out,
dwo_out,
llvm::FileType::ObjectFile,
&cgcx.prof,
)
})?;

And eventually

if (DwoPath) {
raw_fd_ostream DOS(DwoPath, EC, sys::fs::OF_None);
EC.clear();
if (EC)
ErrorInfo = EC.message();
if (ErrorInfo != "") {
LLVMRustSetLastError(ErrorInfo.c_str());
return LLVMRustResult::Failure;
}
buffer_ostream DBOS(DOS);
unwrap(Target)->addPassesToEmitFile(*PM, BOS, &DBOS, FileType, false);
PM->run(*unwrap(M));
} else {
.

So the LLVM change is not needed and the current solution works

@cbeuw
cbeuw requested a review from davidtwcoDecember 11, 2021 11:32

@davidtwcodavidtwco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, comment or two about some changes but broadly what I'd expect.

Comment threadcompiler/rustc_codegen_llvm/src/back/write.rs
Comment threadcompiler/rustc_codegen_llvm/src/back/write.rs
@davidtwco

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Dec 16, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 5e481d0 has been approved by davidtwco

@borsbors 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 16, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 17, 2021
Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF
`--remap-path-prefix` doesn't apply to paths to `.o` (in case of packed) or `.dwo` (in case of unpacked) files in `DW_AT_GNU_dwo_name`. GCC also has this bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91888
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 17, 2021
Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF
`--remap-path-prefix` doesn't apply to paths to `.o` (in case of packed) or `.dwo` (in case of unpacked) files in `DW_AT_GNU_dwo_name`. GCC also has this bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91888
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 1c42199 into rust-lang:masterDec 18, 2021
@rustbotrustbot added this to the 1.59.0 milestone Dec 18, 2021
@cbeuw
cbeuw deleted the remap-dwo-name branch December 18, 2021 21:19
@jieyouxujieyouxu added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-reproducibility Area: Reproducible / deterministic builds labels Aug 14, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)A-reproducibilityArea: Reproducible / deterministic buildsS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

9 participants

@cbeuw@rust-highfive@oli-obk@davidtwco@rust-log-analyzer@bors@apiraino@jieyouxu@rustbot