@@ -35,7 +35,7 @@ use object::{Architecture, BinaryFormat, Endianness, FileFlags, SectionFlags, Se
3535use regex:: Regex ;
3636use tempfile:: Builder as TempFileBuilder ;
3737
38- use std:: ffi:: OsString ;
38+ use std:: ffi:: { OsStr , OsString } ;
3939use std:: lazy:: OnceCell ;
4040use std:: path:: { Path , PathBuf } ;
4141use 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) ;
0 commit comments