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 } ;
77use rustc_errors:: DiagCtxtHandle ;
88use rustc_fs_util:: link_or_copy;
9- use rustc_session:: config:: { Lto , OutputType } ;
9+ use rustc_session:: config:: OutputType ;
1010use rustc_span:: fatal_error:: FatalError ;
1111use rustc_target:: spec:: SplitDebuginfo ;
1212
@@ -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,57 +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- unreachable ! ( ) ;
100- let _timer = cgcx
101- . prof
102- . 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+ ) ;
103111 // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
104112 //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
105113
106114 context. add_command_line_option ( "-flto=auto" ) ;
107115 context. add_command_line_option ( "-flto-partition=one" ) ;
108116 context. add_command_line_option ( "-ffat-lto-objects" ) ;
109117 // 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).
110- context
111- . 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+ ) ;
112122 }
113123 }
114124 }
@@ -231,18 +241,10 @@ pub(crate) fn save_temp_bitcode(
231241 }*/
232242}
233243
234- fn create_msvc_imps < ' gcc > (
235- cgcx : & CodegenContext < GccCodegenBackend > ,
236- context : & Context < ' gcc > ,
237- ) {
244+ /*fn create_msvc_imps<'gcc>(cgcx: &CodegenContext<GccCodegenBackend>, _context: &Context<'gcc>) {
238245 if !cgcx.msvc_imps_needed {
239246 return;
240247 }
241- // The x86 ABI seems to require that leading underscores are added to symbol
242- // names, so we need an extra underscore on x86. There's also a leading
243- // '\x01' here which disables LLVM's symbol mangling (e.g., no extra
244- // underscores added in front).
245- let prefix = if cgcx. target_arch == "x86" { "\x01 __imp__" } else { "\x01 __imp_" } ;
246248
247249 /*unsafe {
248250 let ptr_ty = Type::ptr_llcx(llcx);
@@ -265,4 +267,4 @@ fn create_msvc_imps<'gcc>(
265267 llvm::set_linkage(imp, llvm::Linkage::ExternalLinkage);
266268 }
267269 }*/
268- }
270+ }*/
0 commit comments