about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-12-18 18:08:51 +0000
committerbors <bors@rust-lang.org>2021-12-18 18:08:51 +0000
commit91a0600a5c22b9d159e3c57526af83e71d1120f8 (patch)
tree142be686bed6df375c8d289790e67dd1affd7fd9 /compiler/rustc_codegen_ssa/src/back
parentd3848cb659105d8384c00ba384ec2f6f39c47238 (diff)
parent1ac1f24ddd54865f1719eb8c0e48c4858be1b744 (diff)
downloadrust-91a0600a5c22b9d159e3c57526af83e71d1120f8.tar.gz
rust-91a0600a5c22b9d159e3c57526af83e71d1120f8.zip
Auto merge of #92065 - matthiaskrgr:rollup-qmpcsuj, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91566 (Apply path remapping to DW_AT_GNU_dwo_name when producing split DWARF)
 - #91926 (Remove `in_band_lifetimes` from `rustc_metadata`)
 - #91931 (Remove `in_band_lifetimes` from `rustc_codegen_llvm`)
 - #92024 (rustc_codegen_llvm: Give each codegen unit a unique DWARF name on all platforms, not just Apple ones.)
 - #92037 (Use a const ParamEnv when in default_method_body_is_const)
 - #92047 (Set `RUST_BACKTRACE=0` when running location-detail tests)
 - #92050 (Add a space and 2 grave accents )

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/link.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index e29c109f12d..6271d75e635 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -32,7 +32,7 @@ use cc::windows_registry;
 use regex::Regex;
 use tempfile::Builder as TempFileBuilder;
 
-use std::ffi::OsString;
+use std::ffi::{OsStr, OsString};
 use std::lazy::OnceCell;
 use std::path::{Path, PathBuf};
 use std::process::{ExitStatus, Output, Stdio};
@@ -504,17 +504,19 @@ fn escape_stdout_stderr_string(s: &[u8]) -> String {
 
 const LLVM_DWP_EXECUTABLE: &'static str = "rust-llvm-dwp";
 
-/// Invoke `llvm-dwp` (shipped alongside rustc) to link `dwo` files from Split DWARF into a `dwp`
+/// Invoke `llvm-dwp` (shipped alongside rustc) to link debuginfo in object files into a `dwp`
 /// file.
-fn link_dwarf_object<'a>(sess: &'a Session, executable_out_filename: &Path) {
+fn link_dwarf_object<'a, I>(sess: &'a Session, executable_out_filename: &Path, object_files: I)
+where
+    I: IntoIterator<Item: AsRef<OsStr>>,
+{
     info!("preparing dwp to {}.dwp", executable_out_filename.to_str().unwrap());
 
     let dwp_out_filename = executable_out_filename.with_extension("dwp");
     let mut cmd = Command::new(LLVM_DWP_EXECUTABLE);
-    cmd.arg("-e");
-    cmd.arg(executable_out_filename);
     cmd.arg("-o");
     cmd.arg(&dwp_out_filename);
+    cmd.args(object_files);
 
     let mut new_path = sess.get_tools_search_paths(false);
     if let Some(path) = env::var_os("PATH") {
@@ -898,7 +900,14 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
         SplitDebuginfo::Packed if sess.target.is_like_msvc => {}
 
         // ... and otherwise we're processing a `*.dwp` packed dwarf file.
-        SplitDebuginfo::Packed => link_dwarf_object(sess, &out_filename),
+        // We cannot rely on the .o paths in the exectuable because they may have been
+        // remapped by --remap-path-prefix and therefore invalid. So we need to provide
+        // the .o paths explicitly
+        SplitDebuginfo::Packed => link_dwarf_object(
+            sess,
+            &out_filename,
+            codegen_results.modules.iter().filter_map(|m| m.object.as_ref()),
+        ),
     }
 
     let strip = strip_value(sess);