11use std:: { env, fs} ;
22
3- use gccjit:: { Context , OutputKind } ;
3+ use gccjit:: OutputKind ;
44use rustc_codegen_ssa:: back:: link:: ensure_removed;
55use rustc_codegen_ssa:: back:: write:: { BitcodeSection , CodegenContext , EmitObj , ModuleConfig } ;
66use rustc_codegen_ssa:: { CompiledModule , ModuleCodegen } ;
@@ -34,10 +34,10 @@ pub(crate) unsafe fn codegen(
3434 // TODO: remove this environment variable.
3535 let fat_lto = env:: var ( "EMBED_LTO_BITCODE" ) . as_deref ( ) == Ok ( "1" ) ;
3636
37- if cgcx. msvc_imps_needed {
37+ /* if cgcx.msvc_imps_needed {
3838 println!("************************************************** Imps needed");
3939 create_msvc_imps(cgcx, context);
40- }
40+ }*/
4141
4242 let bc_out = cgcx. output_filenames . temp_path ( OutputType :: Bitcode , module_name) ;
4343 let obj_out = cgcx. output_filenames . temp_path ( OutputType :: Object , module_name) ;
@@ -58,56 +58,67 @@ pub(crate) unsafe fn codegen(
5858 }*/
5959
6060 if config. emit_bc || config. emit_obj == EmitObj :: Bitcode {
61- let _timer = cgcx
62- . prof
63- . generic_activity_with_arg ( "GCC_module_codegen_emit_bitcode" , & * module. name ) ;
61+ let _timer = cgcx. prof . generic_activity_with_arg (
62+ "GCC_module_codegen_emit_bitcode" ,
63+ & * module. name ,
64+ ) ;
6465 context. add_command_line_option ( "-flto=auto" ) ;
6566 context. add_command_line_option ( "-flto-partition=one" ) ;
6667 // TODO: remove since we don't want fat objects when it is for Bitcode only.
6768 context. add_command_line_option ( "-ffat-lto-objects" ) ;
68- context
69- . compile_to_file ( OutputKind :: ObjectFile , bc_out. to_str ( ) . expect ( "path to str" ) ) ;
69+ context. compile_to_file (
70+ OutputKind :: ObjectFile ,
71+ bc_out. to_str ( ) . expect ( "path to str" ) ,
72+ ) ;
7073 }
7174
7275 if config. emit_obj == EmitObj :: ObjectCode ( BitcodeSection :: Full ) {
73- let _timer = cgcx
74- . prof
75- . generic_activity_with_arg ( "GCC_module_codegen_embed_bitcode" , & * module. name ) ;
76+ let _timer = cgcx. prof . generic_activity_with_arg (
77+ "GCC_module_codegen_embed_bitcode" ,
78+ & * module. name ,
79+ ) ;
7680 // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
7781 //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
7882
7983 context. add_command_line_option ( "-flto=auto" ) ;
8084 context. add_command_line_option ( "-flto-partition=one" ) ;
8185 context. add_command_line_option ( "-ffat-lto-objects" ) ;
8286 // TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument).
83- context
84- . compile_to_file ( OutputKind :: ObjectFile , bc_out. to_str ( ) . expect ( "path to str" ) ) ;
87+ context. compile_to_file (
88+ OutputKind :: ObjectFile ,
89+ bc_out. to_str ( ) . expect ( "path to str" ) ,
90+ ) ;
8591 }
86- }
87- else {
92+ } else {
8893 if config. emit_bc || config. emit_obj == EmitObj :: Bitcode {
89- let _timer = cgcx
90- . prof
91- . generic_activity_with_arg ( "GCC_module_codegen_emit_bitcode" , & * module. name ) ;
92- context
93- . compile_to_file ( OutputKind :: ObjectFile , bc_out. to_str ( ) . expect ( "path to str" ) ) ;
94+ let _timer = cgcx. prof . generic_activity_with_arg (
95+ "GCC_module_codegen_emit_bitcode" ,
96+ & * module. name ,
97+ ) ;
98+ context. compile_to_file (
99+ OutputKind :: ObjectFile ,
100+ bc_out. to_str ( ) . expect ( "path to str" ) ,
101+ ) ;
94102 }
95103
96104 if config. emit_obj == EmitObj :: ObjectCode ( BitcodeSection :: Full ) {
97105 // TODO: we might want to emit to emit an error here, saying to set the
98106 // environment variable EMBED_LTO_BITCODE.
99- let _timer = cgcx
100- . prof
101- . generic_activity_with_arg ( "GCC_module_codegen_embed_bitcode" , & * module. name ) ;
107+ let _timer = cgcx. prof . generic_activity_with_arg (
108+ "GCC_module_codegen_embed_bitcode" ,
109+ & * module. name ,
110+ ) ;
102111 // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
103112 //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
104113
105114 context. add_command_line_option ( "-flto=auto" ) ;
106115 context. add_command_line_option ( "-flto-partition=one" ) ;
107116 context. add_command_line_option ( "-ffat-lto-objects" ) ;
108117 // TODO(antoyo): Send -plugin/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/liblto_plugin.so to linker (this should be done when specifying the appropriate rustc cli argument).
109- context
110- . compile_to_file ( OutputKind :: ObjectFile , bc_out. to_str ( ) . expect ( "path to str" ) ) ;
118+ context. compile_to_file (
119+ OutputKind :: ObjectFile ,
120+ bc_out. to_str ( ) . expect ( "path to str" ) ,
121+ ) ;
111122 }
112123 }
113124 }
@@ -230,10 +241,7 @@ pub(crate) fn save_temp_bitcode(
230241 }*/
231242}
232243
233- fn create_msvc_imps < ' gcc > (
234- cgcx : & CodegenContext < GccCodegenBackend > ,
235- _context : & Context < ' gcc > ,
236- ) {
244+ /*fn create_msvc_imps<'gcc>(cgcx: &CodegenContext<GccCodegenBackend>, _context: &Context<'gcc>) {
237245 if !cgcx.msvc_imps_needed {
238246 return;
239247 }
@@ -259,4 +267,4 @@ fn create_msvc_imps<'gcc>(
259267 llvm::set_linkage(imp, llvm::Linkage::ExternalLinkage);
260268 }
261269 }*/
262- }
270+ }*/
0 commit comments