@@ -392,14 +392,48 @@ pub fn phase_5_run_llvm_passes(sess: Session,
392
392
/// This should produce either a finished executable or library.
393
393
pub fn phase_6_link_output ( sess : Session ,
394
394
trans : & CrateTranslation ,
395
- input : & input ,
396
395
outputs : & OutputFilenames ) {
397
- let outputs = time ( sess. time_passes ( ) , "linking" , ( ) , |_|
396
+ time ( sess. time_passes ( ) , "linking" , ( ) , |_|
398
397
link:: link_binary ( sess,
399
398
trans,
400
399
& outputs. obj_filename ,
401
400
& outputs. out_filename ,
402
401
& trans. link ) ) ;
402
+ }
403
+
404
+ pub fn stop_after_phase_3 ( sess : Session ) -> bool {
405
+ if sess. opts . no_trans {
406
+ debug ! ( "invoked with --no-trans, returning early from compile_input" ) ;
407
+ return true ;
408
+ }
409
+ return false ;
410
+ }
411
+
412
+ pub fn stop_after_phase_1 ( sess : Session ) -> bool {
413
+ if sess. opts . parse_only {
414
+ debug ! ( "invoked with --parse-only, returning early from compile_input" ) ;
415
+ return true ;
416
+ }
417
+ return false ;
418
+ }
419
+
420
+ pub fn stop_after_phase_5 ( sess : Session ) -> bool {
421
+ if sess. opts . output_type != link:: output_type_exe {
422
+ debug ! ( "not building executable, returning early from compile_input" ) ;
423
+ return true ;
424
+ }
425
+ return false ;
426
+ }
427
+
428
+ fn write_out_deps ( sess : Session , input : & input , outputs : & OutputFilenames , crate : & ast:: Crate )
429
+ {
430
+ let lm = link:: build_link_meta ( sess, crate . attrs, & outputs. obj_filename ,
431
+ & mut :: util:: sha2:: Sha256 :: new ( ) ) ;
432
+
433
+ let sess_outputs = sess. outputs . borrow ( ) ;
434
+ let out_filenames = sess_outputs. get ( ) . iter ( )
435
+ . map ( |& output| link:: filename_for_input ( & sess, output, & lm, & outputs. out_filename ) )
436
+ . to_owned_vec ( ) ;
403
437
404
438
// Write out dependency rules to the dep-info file if requested with --dep-info
405
439
let deps_filename = match sess. opts . write_dependency_info {
@@ -409,7 +443,7 @@ pub fn phase_6_link_output(sess: Session,
409
443
( true , None ) => match * input {
410
444
file_input( ref input_path) => {
411
445
let filestem = input_path. filestem ( ) . expect ( "input file must have stem" ) ;
412
- let filename = outputs [ 0 ] . dir_path ( ) . join ( filestem) . with_extension ( "d" ) ;
446
+ let filename = out_filenames [ 0 ] . dir_path ( ) . join ( filestem) . with_extension ( "d" ) ;
413
447
filename
414
448
} ,
415
449
str_input( ..) => {
@@ -419,40 +453,17 @@ pub fn phase_6_link_output(sess: Session,
419
453
} ,
420
454
_ => return ,
421
455
} ;
456
+
422
457
// Build a list of files used to compile the output and
423
458
// write Makefile-compatible dependency rules
424
459
let files: ~[ @str ] = sess. codemap . files . iter ( )
425
460
. filter_map ( |fmap| if fmap. is_real_file ( ) { Some ( fmap. name ) } else { None } )
426
461
. collect ( ) ;
427
462
let mut file = io:: File :: create ( & deps_filename) ;
428
- for output in outputs . iter ( ) {
463
+ for path in out_filenames . iter ( ) {
429
464
write ! ( & mut file as & mut Writer ,
430
- "{}: {}\n \n " , output. display( ) , files. connect( " " ) ) ;
431
- }
432
- }
433
-
434
- pub fn stop_after_phase_3 ( sess : Session ) -> bool {
435
- if sess. opts . no_trans {
436
- debug ! ( "invoked with --no-trans, returning early from compile_input" ) ;
437
- return true ;
465
+ "{}: {}\n \n " , path. display( ) , files. connect( " " ) ) ;
438
466
}
439
- return false ;
440
- }
441
-
442
- pub fn stop_after_phase_1 ( sess : Session ) -> bool {
443
- if sess. opts . parse_only {
444
- debug ! ( "invoked with --parse-only, returning early from compile_input" ) ;
445
- return true ;
446
- }
447
- return false ;
448
- }
449
-
450
- pub fn stop_after_phase_5 ( sess : Session ) -> bool {
451
- if sess. opts . output_type != link:: output_type_exe {
452
- debug ! ( "not building executable, returning early from compile_input" ) ;
453
- return true ;
454
- }
455
- return false ;
456
467
}
457
468
458
469
pub fn compile_input ( sess : Session , cfg : ast:: CrateConfig , input : & input ,
@@ -468,6 +479,9 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input,
468
479
} ;
469
480
let outputs = build_output_filenames ( input, outdir, output,
470
481
expanded_crate. attrs , sess) ;
482
+
483
+ write_out_deps ( sess, input, outputs, & expanded_crate) ;
484
+
471
485
let analysis = phase_3_run_analysis_passes ( sess, & expanded_crate) ;
472
486
if stop_after_phase_3 ( sess) { return ; }
473
487
let trans = phase_4_translate_to_llvm ( sess, expanded_crate,
@@ -476,7 +490,7 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input,
476
490
} ;
477
491
phase_5_run_llvm_passes ( sess, & trans, outputs) ;
478
492
if stop_after_phase_5 ( sess) { return ; }
479
- phase_6_link_output ( sess, & trans, input , outputs) ;
493
+ phase_6_link_output ( sess, & trans, outputs) ;
480
494
}
481
495
482
496
struct IdentifiedAnnotation {
0 commit comments