@@ -392,14 +392,48 @@ pub fn phase_5_run_llvm_passes(sess: Session,
392392/// This should produce either a finished executable or library.
393393pub fn phase_6_link_output ( sess : Session ,
394394 trans : & CrateTranslation ,
395- input : & input ,
396395 outputs : & OutputFilenames ) {
397- let outputs = time ( sess. time_passes ( ) , "linking" , ( ) , |_|
396+ time ( sess. time_passes ( ) , "linking" , ( ) , |_|
398397 link:: link_binary ( sess,
399398 trans,
400399 & outputs. obj_filename ,
401400 & outputs. out_filename ,
402401 & 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 ( ) ;
403437
404438 // Write out dependency rules to the dep-info file if requested with --dep-info
405439 let deps_filename = match sess. opts . write_dependency_info {
@@ -409,7 +443,7 @@ pub fn phase_6_link_output(sess: Session,
409443 ( true , None ) => match * input {
410444 file_input( ref input_path) => {
411445 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" ) ;
413447 filename
414448 } ,
415449 str_input( ..) => {
@@ -419,40 +453,17 @@ pub fn phase_6_link_output(sess: Session,
419453 } ,
420454 _ => return ,
421455 } ;
456+
422457 // Build a list of files used to compile the output and
423458 // write Makefile-compatible dependency rules
424459 let files: ~[ @str ] = sess. codemap . files . iter ( )
425460 . filter_map ( |fmap| if fmap. is_real_file ( ) { Some ( fmap. name ) } else { None } )
426461 . collect ( ) ;
427462 let mut file = io:: File :: create ( & deps_filename) ;
428- for output in outputs . iter ( ) {
463+ for path in out_filenames . iter ( ) {
429464 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( " " ) ) ;
438466 }
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 ;
456467}
457468
458469pub 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,
468479 } ;
469480 let outputs = build_output_filenames ( input, outdir, output,
470481 expanded_crate. attrs , sess) ;
482+
483+ write_out_deps ( sess, input, outputs, & expanded_crate) ;
484+
471485 let analysis = phase_3_run_analysis_passes ( sess, & expanded_crate) ;
472486 if stop_after_phase_3 ( sess) { return ; }
473487 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,
476490 } ;
477491 phase_5_run_llvm_passes ( sess, & trans, outputs) ;
478492 if stop_after_phase_5 ( sess) { return ; }
479- phase_6_link_output ( sess, & trans, input , outputs) ;
493+ phase_6_link_output ( sess, & trans, outputs) ;
480494}
481495
482496struct IdentifiedAnnotation {
0 commit comments