@@ -371,14 +371,17 @@ pub fn mangle_internal_name_by_path_and_seq(path: DefPath, flav: &str) -> String
371
371
mangle ( names, None )
372
372
}
373
373
374
- pub fn get_linker ( sess : & Session ) -> ( String , Command ) {
374
+ // The third parameter is for an extra path to add to PATH for MSVC
375
+ // cross linkers for host toolchain DLL dependencies
376
+ pub fn get_linker ( sess : & Session ) -> ( String , Command , Option < PathBuf > ) {
375
377
if let Some ( ref linker) = sess. opts . cg . linker {
376
- ( linker. clone ( ) , Command :: new ( linker) )
378
+ ( linker. clone ( ) , Command :: new ( linker) , None )
377
379
} else if sess. target . target . options . is_like_msvc {
378
- ( "link.exe" . to_string ( ) , msvc:: link_exe_cmd ( sess) )
380
+ let ( cmd, host) = msvc:: link_exe_cmd ( sess) ;
381
+ ( "link.exe" . to_string ( ) , cmd, host)
379
382
} else {
380
383
( sess. target . target . options . linker . clone ( ) ,
381
- Command :: new ( & sess. target . target . options . linker ) )
384
+ Command :: new ( & sess. target . target . options . linker ) , None )
382
385
}
383
386
}
384
387
@@ -388,17 +391,15 @@ pub fn get_ar_prog(sess: &Session) -> String {
388
391
} )
389
392
}
390
393
391
- fn command_path ( sess : & Session ) -> OsString {
394
+ fn command_path ( sess : & Session , extra : Option < PathBuf > ) -> OsString {
392
395
// The compiler's sysroot often has some bundled tools, so add it to the
393
396
// PATH for the child.
394
397
let mut new_path = sess. host_filesearch ( PathKind :: All )
395
398
. get_tools_search_paths ( ) ;
396
399
if let Some ( path) = env:: var_os ( "PATH" ) {
397
400
new_path. extend ( env:: split_paths ( & path) ) ;
398
401
}
399
- if sess. target . target . options . is_like_msvc {
400
- new_path. extend ( msvc:: host_dll_path ( ) ) ;
401
- }
402
+ new_path. extend ( extra) ;
402
403
env:: join_paths ( new_path) . unwrap ( )
403
404
}
404
405
@@ -608,7 +609,7 @@ fn archive_config<'a>(sess: &'a Session,
608
609
src : input. map ( |p| p. to_path_buf ( ) ) ,
609
610
lib_search_paths : archive_search_paths ( sess) ,
610
611
ar_prog : get_ar_prog ( sess) ,
611
- command_path : command_path ( sess) ,
612
+ command_path : command_path ( sess, None ) ,
612
613
}
613
614
}
614
615
@@ -854,8 +855,8 @@ fn link_natively(sess: &Session, dylib: bool,
854
855
out_filename) ;
855
856
856
857
// The invocations of cc share some flags across platforms
857
- let ( pname, mut cmd) = get_linker ( sess) ;
858
- cmd. env ( "PATH" , command_path ( sess) ) ;
858
+ let ( pname, mut cmd, extra ) = get_linker ( sess) ;
859
+ cmd. env ( "PATH" , command_path ( sess, extra ) ) ;
859
860
860
861
let root = sess. target_filesearch ( PathKind :: Native ) . get_lib_path ( ) ;
861
862
cmd. args ( & sess. target . target . options . pre_link_args ) ;
0 commit comments