Set path of the compile unit to the source directory by nagisa · Pull Request #82102 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation30 Commits3 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

nagisa

As part of the effort to implement split dwarf debug info, we ended up
setting the compile unit location to the output directory rather than
the source directory. Furthermore, it seems like we failed to remap the
prefixes for this as well!

The desired behaviour is to instead set the DW_AT_GNU_dwo_name to a
path relative to compiler's working directory. This still allows
debuggers to find the split dwarf files, while not changing the
behaviour of the code that is compiling with regular debug info, and not
changing the compiler's behaviour with regards to reproducibility.

Fixes #82074

cc @alexcrichton @davidtwco

@nagisa

As part of the effort to implement split dwarf debug info, we ended up setting the compile unit location to the output directory rather than the source directory. Furthermore, it seems like we failed to remap the prefixes for this as well!

The desired behaviour is to instead set the DW_AT_GNU_dwo_name to a path relative to compiler's working directory. This still allows debuggers to find the split dwarf files, while not changing the behaviour of the code that is compiling with regular debug info, and not changing the compiler's behaviour with regards to reproducibility.

Fixes rust-lang#82074

@rust-highfive

r? @matthewjasper

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

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

davidtwco

@davidtwco

@davidtwco

r=me unless fixing the test failure requires sufficient changes to warrant another look.

@nagisa

Huh, so what's happening is that llvm-dwp is naively concatenating DW_AT_comp_dir + DW_AT_GNU_dwo_name from DW_TAG_compile_unit. This issue is also reproducible with clang and gcc:

$ clang -gsplit-dwarf /tmp/banana/test.c -c -o /tmp/outdir/foo.o
$ clang outdir/foo.o -o outdir/hm
$ llvm-dwarfdump outdir/hm | grep -C5 foo.dwo

0x00002114: DW_TAG_compile_unit
              DW_AT_stmt_list	(0x000005ae)
              DW_AT_comp_dir	("/tmp")
              DW_AT_GNU_pubnames	(true)
              DW_AT_GNU_dwo_name	("/tmp/outdir/foo.dwo")
              DW_AT_GNU_dwo_id	(0xde4d396f3bf0e257)
              DW_AT_low_pc	(0x0000000000401100)
              DW_AT_high_pc	(0x0000000000401103)
              DW_AT_GNU_addr_base	(0x00000000)
0x00002139: Compile Unit: length = 0x0000001e, format = DWARF32, version = 0x0002, abbr_offset = 0x03c0, addr_size = 0x08 (next unit at 0x0000215b)
$ strace -o trace llvm-dwp -e outdir/hm -o outdir/hm.dwp
error: No such file or directory
$ cat trace | grep foo.dwo
openat(AT_FDCWD, "/tmp/tmp/outdir/foo.dwo", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

From what I can tell the right place to solve this would be in the llvm-dwp tool itself.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@nagisa

@bors r=davidtwco rollup=never

@bors

📌 Commit 956b5ce7a12ba82163dc835a43421d5056800578 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

Feb 17, 2021

@bors

⌛ Testing commit 956b5ce7a12ba82163dc835a43421d5056800578 with merge aaa3ae5fd54761939253c04f4f1e0c238045480c...

@jethrogb

@nagisa

@bors bors added S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

and removed S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

labels

Feb 18, 2021

@bors

This comment has been minimized.

@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-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Feb 18, 2021

@nagisa

@bors

This comment has been minimized.

@bors

📌 Commit beb3f1e885c619f7964a093d72d56446e9c0bdae has been approved by davidtwco

@rust-log-analyzer

This comment has been minimized.

@bors

⌛ Testing commit beb3f1e885c619f7964a093d72d56446e9c0bdae with merge 79516cd72305b88a97aefb8071e57e71693a02a4...

@rust-log-analyzer

This comment has been minimized.

@bors

@bors bors added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

labels

Feb 19, 2021

@nagisa

Make sure that we don't regress setting of the CU directory to the working directory.

@nagisa

@nagisa

@bors

📌 Commit 925ed48 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

Feb 20, 2021

@bors

@bors

@bors bors mentioned this pull request

Feb 23, 2021

Labels

merged-by-bors

This PR was explicitly merged by bors.

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.