-
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
split dwarf doesn't work with crate dependencies #81024
Comments
As of writing, here's what I've figured out - using Compiling
During earlier compilation of
Therefore, it is necessary that DWARF object files from dependencies still exist during the compilation of dependent crates (in I've come up with a some potential approaches which would resolve this issue, and I'd appreciate feedback: Adding a DWARF object output typeUnlike other output files of the compiler, DWARF objects are not requested with the rust/compiler/rustc_session/src/config.rs Lines 241 to 252 in 4275ef6
Instead, when Split DWARF is enabled: DWARF object files are produced whenever an object file is emitted (we produce DWARF objects alongside object files in the same We could choose to add a Through this mechanism, we could ensure that the DWARF object files of dependencies continue to exist after the compilation session and thus would be available for dependent compilations. Adding DWARF objects to rlibsAlternatively, we could add DWARF object files to rlib files during linking, and then in the dependent compilation, before invoking Adding DWARF objects to the rlib would require appending the following snippet.. for dwo in codegen_results.modules.iter().filter_map(|m| m.dwarf_object.as_ref()) {
ab.add_file(dwo);
} ..after this part of the compiler: rust/compiler/rustc_codegen_ssa/src/back/link.rs Lines 302 to 314 in 4275ef6
Reading DWARF objects from the rlib would require similar code to the following function, but with a different value for rust/compiler/rustc_codegen_llvm/src/metadata.rs Lines 21 to 41 in 4275ef6
(The snippet above is from If we don't already, we would need to record the codegen modules produced for the dependency. This would be required to know which sections to load from the rlib and write out for the This is quite a bit more complicated than the first solution, but limits the required changes to only rustc. Always keep DWARF objects for library cratesSimilar to "Adding a DWARF object output type" described above, but instead of having Cargo explicitly request that DWARF objects are kept, infer that a crate is a dependency by checking the crate type is a library and that an rlib is also being produced. I'd appreciate any feedback on which of the above solutions is desirable, or if anyone has any alternatives that I haven't thought of yet. |
I was under the impression that this already happend. At least my FCP proposal for |
I assumed that the |
|
Nominated for discussion for next week's compiler meeting (Zulip discussion) |
As reported in #77117 (comment) (cc @philipc), Split DWARF currently fails when compiling a crate with a dependency.
To reproduce this, compile
backtrace-rs
with the following command:The text was updated successfully, but these errors were encountered: