Skip to content

Commit 4abed50

Browse files
committed
Provide .dwo paths to llvm-dwp explicitly
1 parent e5796c4 commit 4abed50

File tree

2 files changed

+16
-7
lines changed
  • compiler/rustc_codegen_ssa/src/back
  • src/test/run-make-fulldeps/split-dwarf

2 files changed

+16
-7
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use object::{Architecture, BinaryFormat, Endianness, FileFlags, SectionFlags, Se
3535
use regex::Regex;
3636
use tempfile::Builder as TempFileBuilder;
3737

38-
use std::ffi::OsString;
38+
use std::ffi::{OsStr, OsString};
3939
use std::lazy::OnceCell;
4040
use std::path::{Path, PathBuf};
4141
use std::process::{ExitStatus, Output, Stdio};
@@ -639,15 +639,17 @@ const LLVM_DWP_EXECUTABLE: &'static str = "rust-llvm-dwp";
639639

640640
/// Invoke `llvm-dwp` (shipped alongside rustc) to link `dwo` files from Split DWARF into a `dwp`
641641
/// file.
642-
fn link_dwarf_object<'a>(sess: &'a Session, executable_out_filename: &Path) {
642+
fn link_dwarf_object<'a, I>(sess: &'a Session, executable_out_filename: &Path, dwo_files: I)
643+
where
644+
I: IntoIterator<Item: AsRef<OsStr>>,
645+
{
643646
info!("preparing dwp to {}.dwp", executable_out_filename.to_str().unwrap());
644647

645648
let dwp_out_filename = executable_out_filename.with_extension("dwp");
646649
let mut cmd = Command::new(LLVM_DWP_EXECUTABLE);
647-
cmd.arg("-e");
648-
cmd.arg(executable_out_filename);
649650
cmd.arg("-o");
650651
cmd.arg(&dwp_out_filename);
652+
cmd.args(dwo_files);
651653

652654
let mut new_path = sess.get_tools_search_paths(false);
653655
if let Some(path) = env::var_os("PATH") {
@@ -1031,7 +1033,14 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
10311033
SplitDebuginfo::Packed if sess.target.is_like_msvc => {}
10321034

10331035
// ... and otherwise we're processing a `*.dwp` packed dwarf file.
1034-
SplitDebuginfo::Packed => link_dwarf_object(sess, &out_filename),
1036+
// We cannot rely on the .dwo paths in the exectuable because they may have been
1037+
// remapped by --remap-path-prefix and therefore invalid. So we need to provide
1038+
// the .dwo paths explicitly
1039+
SplitDebuginfo::Packed => link_dwarf_object(
1040+
sess,
1041+
&out_filename,
1042+
codegen_results.modules.iter().filter_map(|m| m.dwarf_object.as_ref()),
1043+
),
10351044
}
10361045

10371046
let strip = strip_value(sess);

src/test/run-make-fulldeps/split-dwarf/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
all: packed remapped
66

77
remapped:
8-
$(RUSTC) -Z unstable-options -C split-debuginfo=packed -C debuginfo=2 --remap-path-prefix $$PWD= foo.rs -g
8+
$(RUSTC) -Z unstable-options -C split-debuginfo=packed -C debuginfo=2 --remap-path-prefix $$PWD=/a foo.rs -g
99
objdump -Wi $(TMPDIR)/foo | grep $$PWD && exit 1 || exit 0
1010

11-
$(RUSTC) -Z unstable-options -C split-debuginfo=unpacked -C debuginfo=2 --remap-path-prefix $$PWD= foo.rs -g
11+
$(RUSTC) -Z unstable-options -C split-debuginfo=unpacked -C debuginfo=2 --remap-path-prefix $$PWD=/a foo.rs -g
1212
objdump -Wi $(TMPDIR)/foo | grep $$PWD && exit 1 || exit 0
1313

1414
packed:

0 commit comments

Comments
 (0)