Skip to content

cg_llvm: split dwarf support#77117

Merged
bors merged 10 commits intorust-lang:masterfrom
davidtwco:issue-34651-split-dwarf
Dec 16, 2020
Merged

cg_llvm: split dwarf support#77117
bors merged 10 commits intorust-lang:masterfrom
davidtwco:issue-34651-split-dwarf

Conversation

@davidtwco
Copy link
Copy Markdown
Member

@davidtwco davidtwco commented Sep 23, 2020

cc #34651

This PR adds initial support for Split DWARF to rustc, based on the implementation in Clang.

Current Status

This PR currently has functioning split-dwarf, running rustc with -Zsplit-dwarf=split when compiling a binary will produce a dwp alongside the binary, which contains the linked dwarf objects.

$ rustc -Cdebuginfo=2 -Zsplit-dwarf=split -C save-temps ./foo.rs
$ ls foo*
foo
foo.belfx9afw9cmv8.rcgu.dwo
foo.belfx9afw9cmv8.rcgu.o
foo.foo.7rcbfp3g-cgu.0.rcgu.dwo
foo.foo.7rcbfp3g-cgu.0.rcgu.o
foo.foo.7rcbfp3g-cgu.1.rcgu.dwo
foo.foo.7rcbfp3g-cgu.1.rcgu.o
foo.foo.7rcbfp3g-cgu.2.rcgu.dwo
foo.foo.7rcbfp3g-cgu.2.rcgu.o
foo.foo.7rcbfp3g-cgu.3.rcgu.dwo
foo.foo.7rcbfp3g-cgu.3.rcgu.o
foo.foo.7rcbfp3g-cgu.4.rcgu.dwo
foo.foo.7rcbfp3g-cgu.4.rcgu.o
foo.foo.7rcbfp3g-cgu.5.rcgu.dwo
foo.foo.7rcbfp3g-cgu.5.rcgu.o
foo.foo.7rcbfp3g-cgu.6.rcgu.dwo
foo.foo.7rcbfp3g-cgu.6.rcgu.o
foo.foo.7rcbfp3g-cgu.7.rcgu.dwo
foo.foo.7rcbfp3g-cgu.7.rcgu.o
foo.dwp
foo.rs
$ readelf -wi foo.foo.7rcbfp3g-cgu.0.rcgu.o
# ...
  Compilation Unit @ offset 0x90:
   Length:        0x2c (32-bit)
   Version:       4
   Abbrev Offset: 0x5b
   Pointer Size:  8
 <0><9b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <9c>   DW_AT_stmt_list   : 0xe8
    <a0>   DW_AT_comp_dir    : (indirect string, offset: 0x13b): /home/david/Projects/rust/rust0
    <a4>   DW_AT_GNU_dwo_name: (indirect string, offset: 0x15b): foo.foo.7rcbfp3g-cgu.0.rcgu.dwo
    <a8>   DW_AT_GNU_dwo_id  : 0x357472a2b032d7b9
    <b0>   DW_AT_low_pc      : 0x0
    <b8>   DW_AT_ranges      : 0x40
    <bc>   DW_AT_GNU_addr_base: 0x0
# ...
To-Do

I've opened this PR as a draft to get feedback and work out how we'd expect rustc to work when Split DWARF is requested. It might be easier to read the PR commit-by-commit.

  • Add error when Split DWARF is requested on platforms where it doesn't make sense.
  • Determine whether or not there should be a single dwo output from rustc, or one per codegen-unit as exists currently.
  • Add tests.
  • Fix single mode - currently single mode doesn't change the invocation of addPassesToEmitFile, which is correct, but it also needs to change the split dwarf path provided to createCompileUnit and createTargetMachine so that it's just the final binary (currently it is still a non-existent dwo file).

r? @nagisa
cc @michaelwoerister @eddyb @alexcrichton @rust-lang/wg-incr-comp

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.