@@ -30,6 +30,7 @@ use util::fs::fix_windows_verbatim_for_gcc;
30
30
use rustc_back:: tempdir:: TempDir ;
31
31
32
32
use std:: env;
33
+ use std:: ffi:: OsString ;
33
34
use std:: fs:: { self , PathExt } ;
34
35
use std:: io:: { self , Read , Write } ;
35
36
use std:: mem;
@@ -370,6 +371,17 @@ pub fn get_ar_prog(sess: &Session) -> String {
370
371
} )
371
372
}
372
373
374
+ fn command_path ( sess : & Session ) -> OsString {
375
+ // The compiler's sysroot often has some bundled tools, so add it to the
376
+ // PATH for the child.
377
+ let mut new_path = sess. host_filesearch ( PathKind :: All )
378
+ . get_tools_search_paths ( ) ;
379
+ if let Some ( path) = env:: var_os ( "PATH" ) {
380
+ new_path. extend ( env:: split_paths ( & path) ) ;
381
+ }
382
+ env:: join_paths ( new_path) . unwrap ( )
383
+ }
384
+
373
385
pub fn remove ( sess : & Session , path : & Path ) {
374
386
match fs:: remove_file ( path) {
375
387
Ok ( ..) => { }
@@ -554,6 +566,7 @@ fn link_rlib<'a>(sess: &'a Session,
554
566
slib_prefix : sess. target . target . options . staticlib_prefix . clone ( ) ,
555
567
slib_suffix : sess. target . target . options . staticlib_suffix . clone ( ) ,
556
568
ar_prog : get_ar_prog ( sess) ,
569
+ command_path : command_path ( sess) ,
557
570
} ;
558
571
let mut ab = ArchiveBuilder :: create ( config) ;
559
572
ab. add_file ( obj_filename) . unwrap ( ) ;
@@ -796,15 +809,7 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
796
809
// The invocations of cc share some flags across platforms
797
810
let pname = get_cc_prog ( sess) ;
798
811
let mut cmd = Command :: new ( & pname) ;
799
-
800
- // The compiler's sysroot often has some bundled tools, so add it to the
801
- // PATH for the child.
802
- let mut new_path = sess. host_filesearch ( PathKind :: All )
803
- . get_tools_search_paths ( ) ;
804
- if let Some ( path) = env:: var_os ( "PATH" ) {
805
- new_path. extend ( env:: split_paths ( & path) ) ;
806
- }
807
- cmd. env ( "PATH" , env:: join_paths ( new_path) . unwrap ( ) ) ;
812
+ cmd. env ( "PATH" , command_path ( sess) ) ;
808
813
809
814
let root = sess. target_filesearch ( PathKind :: Native ) . get_lib_path ( ) ;
810
815
cmd. args ( & sess. target . target . options . pre_link_args ) ;
@@ -1187,6 +1192,7 @@ fn add_upstream_rust_crates(cmd: &mut Linker, sess: &Session,
1187
1192
slib_prefix : sess. target . target . options . staticlib_prefix . clone ( ) ,
1188
1193
slib_suffix : sess. target . target . options . staticlib_suffix . clone ( ) ,
1189
1194
ar_prog : get_ar_prog ( sess) ,
1195
+ command_path : command_path ( sess) ,
1190
1196
} ;
1191
1197
let mut archive = Archive :: open ( config) ;
1192
1198
archive. remove_file ( & format ! ( "{}.o" , name) ) ;
0 commit comments