-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
cg_llvm: split dwarf support #77117
cg_llvm: split dwarf support #77117
Conversation
What happens when you compile a Cargo package in debug mode, with some dependencies? Debug mode should default to Would be nice if it were possible to combine the files cheaply, as managing one Other than this, this PR is great! I remember how much better using split DWARF was when compiling LLVM in debug mode. It also reminds me that I want to eventually look at perhaps deduplicating some of the DWARF definitions (which get duplicated through instantiation in separate CGUs), and being able to operate on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://gcc.gnu.org/wiki/DebugFission and https://gcc.gnu.org/wiki/DebugFissionDWP have some discussion on merging the dwo files into a single file.
So far what I'm seeing looks good to me!
} | ||
/// Configuration passed to the function returned by the `target_machine_factory`. | ||
pub struct TargetMachineFactoryConfig<'a> { | ||
/// Split DWARF is enabled in LLVM by checking that `TM.MCOptions.SplitDwarfFile` isn't empty, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm… this probably should not be LLVM-specific, but I don’t yet know how the alternative backends could handle this being set (error out? transparently ignore?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added to this commit to note that non-LLVM backends can ignore this if they don't need it for their own Split DWARF support.
As far as I can tell (having just had a quick look at |
This comment has been minimized.
This comment has been minimized.
0d82e49
to
39cb612
Compare
I've revisited this today and made some good progress - I've discovered that There's still some work to be done on this PR but this is a reasonable step forward. cc @Mark-Simulacrum for some bootstrap changes (see e83d81b at time of writing) |
This comment has been minimized.
This comment has been minimized.
39cb612
to
ff83683
Compare
ff83683
to
c367af4
Compare
Pushed another update - added a compare mode that makes debuginfo tests also run with Split DWARF - which identified an issue that I've resolved. That might not be the long-term approach we want for testing Split DWARF, but it worked for now and I'm open to ideas. Only thing I identified initially that I've yet to do is add an error when this is used on platforms where it wouldn't make sense, but I'm not sure if that's actually something we want - would appreciate feedback on that point. |
c367af4
to
8ad0de9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bors r+
@bors rollup=iffy |
Should the flag for this be moved to I'd also like @Mark-Simulacrum to review the changes to bootstrap. I'm not sure if there's any downsides to adding a new tool to the sysroot. With that said, Split DWARF in this PR isn't enabled by default or accessible outside of nightly - so we can still make changes (except for the dwp tool in the sysroot, I suppose). |
Nah, move from
Did you mean not enabled by default? |
I think the main downside to adding the extra tool is that it increases our dependence on LLVM a bit further - I don't think it is a sufficient concern to block this, though. When we get closer to stabilization we can consider this and perhaps look at alternatives (e.g. a rust alternative to dwp). Otherwise the bootstrap changes seem fine. |
This commit makes minor changes to the cranelift backend so that it can build given changes in cg_ssa for Split DWARF. Signed-off-by: David Wood <david@davidtw.co>
This commit adds a run-make-fulldeps test which checks that a DWARF package file is emitted. Signed-off-by: David Wood <david@davidtw.co>
This commit adds a Split DWARF compare mode to compiletest so that debuginfo tests are also tested using Split DWARF in split mode (and manually in single mode). Signed-off-by: David Wood <david@davidtw.co>
llvm-dwp concatenates `DW_AT_comp_dir` with `DW_AT_GNU_dwo_name` (only when `DW_AT_comp_dir` exists), which can result in it failing to find the DWARF object files. In earlier testing, `DW_AT_comp_dir` wasn't present in the final object and the current directory was the output directory. When running tests through compiletest, the working directory of the compilation is different from output directory and that resulted in `DW_AT_comp_dir` being in the object file (and set to the current working directory, rather than the output directory), and `DW_AT_GNU_dwo_name` being set to the full path (rather than just the filename), so llvm-dwp was failing. This commit changes the compilation directory provided to LLVM to match the output directory, where DWARF objects are output; and ensures that only the filename is used for `DW_AT_GNU_dwo_name`. Signed-off-by: David Wood <david@davidtw.co>
e6bb400
to
ee073b5
Compare
@bors r=nagisa |
📌 Commit ee073b5 has been approved by |
☀️ Test successful - checks-actions |
This commit includes the `llvm-dwp` tool in the CI LLVM (which rustc developers can download instead of building LLVM locally) - `llvm-dwp` is required by Split DWARF which landed in PR rust-lang#77117. Signed-off-by: David Wood <david@davidtw.co>
…llvm, r=Mark-Simulacrum bootstrap: include llvm-dwp in CI LLVM Fixes rust-lang#80086. This PR includes the `llvm-dwp` tool in the CI LLVM (which rustc developers can download instead of building LLVM locally) - `llvm-dwp` is required by Split DWARF which landed in PR rust-lang#77117. r? `@Mark-Simulacrum`
@davidtwco Is there a reason this requires
|
@philipc |
The command is as given above (
I wouldn't expect a problem like that to be fixed by using |
I wouldn't either. I'll take a look at this and see if I can work out what is happening as soon as I can. |
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 adwp
alongside the binary, which contains the linked dwarf objects.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.
dwo
output from rustc, or one per codegen-unit as exists currently.single
mode - currently single mode doesn't change the invocation ofaddPassesToEmitFile
, which is correct, but it also needs to change the split dwarf path provided tocreateCompileUnit
andcreateTargetMachine
so that it's just the final binary (currently it is still a non-existentdwo
file).r? @nagisa
cc @michaelwoerister @eddyb @alexcrichton @rust-lang/wg-incr-comp