@@ -751,44 +751,53 @@ pub(crate) unsafe fn codegen(
751
751
} ) ?;
752
752
}
753
753
754
- if config_emit_object_code {
755
- if !config. no_integrated_as {
756
- let _timer = cgcx
757
- . prof
758
- . generic_activity_with_arg ( "LLVM_module_codegen_emit_obj" , & module. name [ ..] ) ;
759
- with_codegen ( tm, llmod, config. no_builtins , |cpm| {
760
- write_output_file (
761
- diag_handler,
762
- tm,
763
- cpm,
764
- llmod,
765
- & obj_out,
766
- llvm:: FileType :: ObjectFile ,
767
- )
768
- } ) ?;
769
- } else {
770
- let _timer = cgcx
771
- . prof
772
- . generic_activity_with_arg ( "LLVM_module_codegen_asm_to_obj" , & module. name [ ..] ) ;
773
- let assembly = cgcx. output_filenames . temp_path ( OutputType :: Assembly , module_name) ;
774
- run_assembler ( cgcx, diag_handler, & assembly, & obj_out) ;
775
-
776
- if !config. emit_asm && !cgcx. save_temps {
777
- drop ( fs:: remove_file ( & assembly) ) ;
754
+ match config. emit_obj {
755
+ EmitObj :: ObjectCode ( _) => {
756
+ if !config. no_integrated_as {
757
+ let _timer = cgcx. prof . generic_activity_with_arg (
758
+ "LLVM_module_codegen_emit_obj" ,
759
+ & module. name [ ..] ,
760
+ ) ;
761
+ with_codegen ( tm, llmod, config. no_builtins , |cpm| {
762
+ write_output_file (
763
+ diag_handler,
764
+ tm,
765
+ cpm,
766
+ llmod,
767
+ & obj_out,
768
+ llvm:: FileType :: ObjectFile ,
769
+ )
770
+ } ) ?;
771
+ } else {
772
+ let _timer = cgcx. prof . generic_activity_with_arg (
773
+ "LLVM_module_codegen_asm_to_obj" ,
774
+ & module. name [ ..] ,
775
+ ) ;
776
+ let assembly =
777
+ cgcx. output_filenames . temp_path ( OutputType :: Assembly , module_name) ;
778
+ run_assembler ( cgcx, diag_handler, & assembly, & obj_out) ;
779
+
780
+ if !config. emit_asm && !cgcx. save_temps {
781
+ drop ( fs:: remove_file ( & assembly) ) ;
782
+ }
778
783
}
779
784
}
780
- } else if config. emit_obj == EmitObj :: Bitcode {
781
- debug ! ( "copying bitcode {:?} to obj {:?}" , bc_out, obj_out) ;
782
- if let Err ( e) = link_or_copy ( & bc_out, & obj_out) {
783
- diag_handler. err ( & format ! ( "failed to copy bitcode to object file: {}" , e) ) ;
784
- }
785
785
786
- if !config. emit_bc {
787
- debug ! ( "removing_bitcode {:?}" , bc_out) ;
788
- if let Err ( e) = fs:: remove_file ( & bc_out) {
789
- diag_handler. err ( & format ! ( "failed to remove bitcode: {}" , e) ) ;
786
+ EmitObj :: Bitcode => {
787
+ debug ! ( "copying bitcode {:?} to obj {:?}" , bc_out, obj_out) ;
788
+ if let Err ( e) = link_or_copy ( & bc_out, & obj_out) {
789
+ diag_handler. err ( & format ! ( "failed to copy bitcode to object file: {}" , e) ) ;
790
+ }
791
+
792
+ if !config. emit_bc {
793
+ debug ! ( "removing_bitcode {:?}" , bc_out) ;
794
+ if let Err ( e) = fs:: remove_file ( & bc_out) {
795
+ diag_handler. err ( & format ! ( "failed to remove bitcode: {}" , e) ) ;
796
+ }
790
797
}
791
798
}
799
+
800
+ EmitObj :: None => { }
792
801
}
793
802
794
803
drop ( handlers) ;
0 commit comments