about summary refs log tree commit diff
path: root/compiler/rustc_session
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2020-11-08 17:17:37 +0000
committerDavid Wood <david@davidtw.co>2020-12-16 10:33:52 +0000
commitee073b5ec54a13b393071298acc54e1fd28cfcdf (patch)
treef25b341a81c834fae5e49f595c3f418808dd4489 /compiler/rustc_session
parent99ad915e32744eb771e9a0968bf7d0d1f52a9a07 (diff)
downloadrust-ee073b5ec54a13b393071298acc54e1fd28cfcdf.tar.gz
rust-ee073b5ec54a13b393071298acc54e1fd28cfcdf.zip
cg_llvm: split dwarf filename and comp dir
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>
Diffstat (limited to 'compiler/rustc_session')
-rw-r--r--compiler/rustc_session/src/config.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index b3d4c6e3ec7..c20b11656b2 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -617,9 +617,20 @@ impl OutputFilenames {
         path
     }
 
+    /// Returns the name of the Split DWARF file - this can differ depending on which Split DWARF
+    /// mode is being used, which is the logic that this function is intended to encapsulate.
+    pub fn split_dwarf_filename(
+        &self,
+        split_dwarf_kind: SplitDwarfKind,
+        cgu_name: Option<&str>,
+    ) -> Option<PathBuf> {
+        self.split_dwarf_path(split_dwarf_kind, cgu_name)
+            .map(|path| path.strip_prefix(&self.out_directory).unwrap_or(&path).to_path_buf())
+    }
+
     /// Returns the path for the Split DWARF file - this can differ depending on which Split DWARF
     /// mode is being used, which is the logic that this function is intended to encapsulate.
-    pub fn split_dwarf_file(
+    pub fn split_dwarf_path(
         &self,
         split_dwarf_kind: SplitDwarfKind,
         cgu_name: Option<&str>,