Skip to content
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

fix(trim-paths): trim SO and DW_AT_comp_dir symbols for root DI node #118518

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,22 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
// FIXME(#41252) Remove "clang LLVM" if we can get GDB and LLVM to play nice.
let producer = format!("clang LLVM ({rustc_producer})");

use rustc_session::RemapFileNameExt;
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
let work_dir = tcx.sess.opts.working_dir.for_codegen(tcx.sess).to_string_lossy();
debug!(?name_in_debuginfo, "build_compile_unit_di_node");

// Path of working directory in the root DI node seems to be embedded in
// executables. Hence, we trim them when the scope of `unsplit-debuginfo`
// is present, as if it is kinda a "unsplit" debuginfo.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been able to verify that this is indeed the case for DWARF dwps (i.e. the DW_AT_comp_dir is only contained in the binary, not in the dwp). However, I'm not sure that this behavior is guaranteed, so I think we should test that the dwp and dwo files don't contain the compiler's working directory at all.

use rustc_session::config::RemapPathScopeComponents;
use rustc_session::RemapFileNameExt;
let work_dir = tcx
.sess
.opts
.working_dir
.for_scope(tcx.sess, RemapPathScopeComponents::UNSPLIT_DEBUGINFO)
.to_string_lossy();
debug!(?work_dir, "build_compile_unit_di_node");

let output_filenames = tcx.output_filenames(());
let split_name = if tcx.sess.target_can_use_split_dwarf() {
output_filenames
Expand Down
Loading
Loading