@@ -35,7 +35,7 @@ use object::{Architecture, BinaryFormat, Endianness, FileFlags, SectionFlags, Se
35
35
use regex:: Regex ;
36
36
use tempfile:: Builder as TempFileBuilder ;
37
37
38
- use std:: ffi:: OsString ;
38
+ use std:: ffi:: { OsStr , OsString } ;
39
39
use std:: lazy:: OnceCell ;
40
40
use std:: path:: { Path , PathBuf } ;
41
41
use std:: process:: { ExitStatus , Output , Stdio } ;
@@ -639,15 +639,17 @@ const LLVM_DWP_EXECUTABLE: &'static str = "rust-llvm-dwp";
639
639
640
640
/// Invoke `llvm-dwp` (shipped alongside rustc) to link `dwo` files from Split DWARF into a `dwp`
641
641
/// 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
+ {
643
646
info ! ( "preparing dwp to {}.dwp" , executable_out_filename. to_str( ) . unwrap( ) ) ;
644
647
645
648
let dwp_out_filename = executable_out_filename. with_extension ( "dwp" ) ;
646
649
let mut cmd = Command :: new ( LLVM_DWP_EXECUTABLE ) ;
647
- cmd. arg ( "-e" ) ;
648
- cmd. arg ( executable_out_filename) ;
649
650
cmd. arg ( "-o" ) ;
650
651
cmd. arg ( & dwp_out_filename) ;
652
+ cmd. args ( dwo_files) ;
651
653
652
654
let mut new_path = sess. get_tools_search_paths ( false ) ;
653
655
if let Some ( path) = env:: var_os ( "PATH" ) {
@@ -1031,7 +1033,14 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
1031
1033
SplitDebuginfo :: Packed if sess. target . is_like_msvc => { }
1032
1034
1033
1035
// ... 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
+ ) ,
1035
1044
}
1036
1045
1037
1046
let strip = strip_value ( sess) ;
0 commit comments