@@ -32,6 +32,7 @@ use serialize::{json, Encodable};
3232
3333use std:: io;
3434use std:: io:: fs;
35+ use std:: os;
3536use arena:: TypedArena ;
3637use syntax:: ast;
3738use syntax:: attr;
@@ -258,18 +259,26 @@ pub fn phase_2_configure_and_expand(sess: &Session,
258259 // dependent dlls. Note that this uses cfg!(windows) as opposed to
259260 // targ_cfg because syntax extensions are always loaded for the host
260261 // compiler, not for the target.
262+ let mut _old_path = String :: new ( ) ;
261263 if cfg ! ( windows) {
262- sess. host_filesearch ( ) . add_dylib_search_paths ( ) ;
264+ _old_path = os:: getenv ( "PATH" ) . unwrap_or ( _old_path) ;
265+ let mut new_path = sess. host_filesearch ( ) . get_dylib_search_paths ( ) ;
266+ new_path. push_all_move ( os:: split_paths ( _old_path. as_slice ( ) ) ) ;
267+ os:: setenv ( "PATH" , os:: join_paths ( new_path. as_slice ( ) ) . unwrap ( ) ) ;
263268 }
264269 let cfg = syntax:: ext:: expand:: ExpansionConfig {
265270 deriving_hash_type_parameter : sess. features . default_type_params . get ( ) ,
266271 crate_name : crate_name. to_string ( ) ,
267272 } ;
268- syntax:: ext:: expand:: expand_crate ( & sess. parse_sess ,
273+ let ret = syntax:: ext:: expand:: expand_crate ( & sess. parse_sess ,
269274 cfg,
270275 macros,
271276 syntax_exts,
272- krate)
277+ krate) ;
278+ if cfg ! ( windows) {
279+ os:: setenv ( "PATH" , _old_path) ;
280+ }
281+ ret
273282 }
274283 ) ;
275284
@@ -509,11 +518,18 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
509518pub fn phase_6_link_output ( sess : & Session ,
510519 trans : & CrateTranslation ,
511520 outputs : & OutputFilenames ) {
521+ let old_path = os:: getenv ( "PATH" ) . unwrap_or_else ( ||String :: new ( ) ) ;
522+ let mut new_path = os:: split_paths ( old_path. as_slice ( ) ) ;
523+ new_path. push_all_move ( sess. host_filesearch ( ) . get_tools_search_paths ( ) ) ;
524+ os:: setenv ( "PATH" , os:: join_paths ( new_path. as_slice ( ) ) . unwrap ( ) ) ;
525+
512526 time ( sess. time_passes ( ) , "linking" , ( ) , |_|
513527 link:: link_binary ( sess,
514528 trans,
515529 outputs,
516530 trans. link . crate_name . as_slice ( ) ) ) ;
531+
532+ os:: setenv ( "PATH" , old_path) ;
517533}
518534
519535pub fn stop_after_phase_3 ( sess : & Session ) -> bool {
0 commit comments