cg: split dwarf for crate dependencies by davidtwco · Pull Request #89819 · rust...
source link: https://github.com/rust-lang/rust/pull/89819
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Fixes #81024.
-
In #79570,
-Z split-dwarf-kind={none,single,split}
was replaced by-C split-debuginfo={off,packed,unpacked}
.-C split-debuginfo
's packed and unpacked aren't exact parallels to single and split, respectively.On Unix,
-C split-debuginfo=packed
will put debuginfo in object files and package debuginfo into a DWARF package file (.dwp
) and-C split-debuginfo=unpacked
will put debuginfo in dwarf object files and won't package it.In the initial implementation of Split DWARF, split mode wrote sections which did not require relocation into a DWARF object (
.dwo
) file which was ignored by the linker and then packaged those DWARF objects into DWARF packages (.dwp
). In single mode, sections which did not require relocation were written into object files but ignored by the linker and were not packaged. However, both split and single modes could be packaged or not, the primary difference in behaviour was where the debuginfo sections that did not require link-time relocation were written (in a DWARF object or the object file).In the first commit of this PR, I re-introduce a
-Z split-dwarf-kind
flag, which can be used to pick between split and single modes when-C split-debuginfo
is used to enable Split DWARF (either packed or unpacked). -
Split DWARF packaging requires all of the object files to exist, including those in dependencies. Therefore, the second commit of this PR makes rustc keep all objects or dwarf objects for unpacked mode and if the crate is a dependency in packed mode (determined by heuristic: if no linking is taking place), then objects or dwarf objects are kept. Objects are kept if
-Z split-dwarf-kind
isSplitDwarfKind::Single
, and dwarf objects ifSplitDwarfKind::Split
.There are other approaches that could be taken to supporting packed Split DWARF with crate dependencies but this seemed like the least complicated and was contained to only rustc. Other potential approaches are described in #81024 (comment), I'm happy to change the approach I've taken here if it isn't what we're looking for. See #89819 (comment) for the current approach.
-
There's still a dependency on
llvm-dwp
after this change, which we probably want to move away from but that seems out-of-scope for this PR. Ideally, Split DWARF (in packed or unpacked modes) will be usable on nightly after this lands. If there aren't any bugs reported then it's possible we could allow Split DWARF to be used on stable after this change, it depends whether or not switching away fromllvm-dwp
later would break any guarantees, or whether we'd want to change how we handle this cross-crate case in future. See #89819 (comment).
r? @nagisa
cc @alexcrichton
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK