@@ -32,6 +32,7 @@ use serialize::{json, Encodable};
32
32
33
33
use std:: io;
34
34
use std:: io:: fs;
35
+ use std:: os;
35
36
use arena:: TypedArena ;
36
37
use syntax:: ast;
37
38
use syntax:: attr;
@@ -258,18 +259,26 @@ pub fn phase_2_configure_and_expand(sess: &Session,
258
259
// dependent dlls. Note that this uses cfg!(windows) as opposed to
259
260
// targ_cfg because syntax extensions are always loaded for the host
260
261
// compiler, not for the target.
262
+ let mut _old_path = String :: new ( ) ;
261
263
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 ( ) ) ;
263
268
}
264
269
let cfg = syntax:: ext:: expand:: ExpansionConfig {
265
270
deriving_hash_type_parameter : sess. features . default_type_params . get ( ) ,
266
271
crate_name : crate_name. to_string ( ) ,
267
272
} ;
268
- syntax:: ext:: expand:: expand_crate ( & sess. parse_sess ,
273
+ let ret = syntax:: ext:: expand:: expand_crate ( & sess. parse_sess ,
269
274
cfg,
270
275
macros,
271
276
syntax_exts,
272
- krate)
277
+ krate) ;
278
+ if cfg ! ( windows) {
279
+ os:: setenv ( "PATH" , _old_path) ;
280
+ }
281
+ ret
273
282
}
274
283
) ;
275
284
@@ -509,11 +518,18 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
509
518
pub fn phase_6_link_output ( sess : & Session ,
510
519
trans : & CrateTranslation ,
511
520
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
+
512
526
time ( sess. time_passes ( ) , "linking" , ( ) , |_|
513
527
link:: link_binary ( sess,
514
528
trans,
515
529
outputs,
516
530
trans. link . crate_name . as_slice ( ) ) ) ;
531
+
532
+ os:: setenv ( "PATH" , old_path) ;
517
533
}
518
534
519
535
pub fn stop_after_phase_3 ( sess : & Session ) -> bool {
0 commit comments