@@ -31,14 +31,9 @@ pub(crate) unsafe fn codegen(
3131
3232 // NOTE: Only generate object files with GIMPLE when this environment variable is set for
3333 // now because this requires a particular setup (same gcc/lto1/lto-wrapper commit as libgccjit).
34- // TODO: remove this environment variable.
34+ // TODO(antoyo) : remove this environment variable.
3535 let fat_lto = env:: var ( "EMBED_LTO_BITCODE" ) . as_deref ( ) == Ok ( "1" ) ;
3636
37- /*if cgcx.msvc_imps_needed {
38- println!("************************************************** Imps needed");
39- create_msvc_imps(cgcx, context);
40- }*/
41-
4237 let bc_out = cgcx. output_filenames . temp_path ( OutputType :: Bitcode , module_name) ;
4338 let obj_out = cgcx. output_filenames . temp_path ( OutputType :: Object , module_name) ;
4439
@@ -64,7 +59,7 @@ pub(crate) unsafe fn codegen(
6459 ) ;
6560 context. add_command_line_option ( "-flto=auto" ) ;
6661 context. add_command_line_option ( "-flto-partition=one" ) ;
67- // TODO: remove since we don't want fat objects when it is for Bitcode only.
62+ // TODO(antoyo) : remove since we don't want fat objects when it is for Bitcode only.
6863 context. add_command_line_option ( "-ffat-lto-objects" ) ;
6964 context. compile_to_file (
7065 OutputKind :: ObjectFile ,
@@ -102,7 +97,7 @@ pub(crate) unsafe fn codegen(
10297 }
10398
10499 if config. emit_obj == EmitObj :: ObjectCode ( BitcodeSection :: Full ) {
105- // TODO: we might want to emit to emit an error here, saying to set the
100+ // TODO(antoyo) : we might want to emit to emit an error here, saying to set the
106101 // environment variable EMBED_LTO_BITCODE.
107102 let _timer = cgcx. prof . generic_activity_with_arg (
108103 "GCC_module_codegen_embed_bitcode" ,
@@ -111,12 +106,6 @@ pub(crate) unsafe fn codegen(
111106 // TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
112107 //embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
113108
114- // TODO: check if this condition makes sense.
115- if fat_lto {
116- context. add_command_line_option ( "-flto=auto" ) ;
117- context. add_command_line_option ( "-flto-partition=one" ) ;
118- context. add_command_line_option ( "-ffat-lto-objects" ) ;
119- }
120109 // 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).
121110 context. compile_to_file (
122111 OutputKind :: ObjectFile ,
@@ -172,8 +161,6 @@ pub(crate) unsafe fn codegen(
172161 // lto1: internal compiler error: decompressed stream: Destination buffer is too small
173162 // TODO: since we do not do LTO when the linker is invoked anymore, perhaps
174163 // the following flag is not necessary anymore.
175- // TODO: also, perhaps compiling the gcc driver in the CI is not necessary
176- // anymore.
177164 context. add_driver_option ( "-fuse-linker-plugin" ) ;
178165 }
179166
@@ -182,15 +169,6 @@ pub(crate) unsafe fn codegen(
182169 // /usr/bin/ld: cannot find -lgcc_s: No such file or directory
183170 context. add_driver_option ( "-nostdlib" ) ;
184171
185- // NOTE: this doesn't actually generate an executable. With the above flags, it combines the .o files together in another .o.
186- // FIXME FIXME: this produces an object file with GIMPLE IR, but it should
187- // produce an object file with machine code.
188- //println!("LTO-ed object file: {:?}", obj_out);
189- /*context.compile_to_file(
190- OutputKind::Executable,
191- obj_out.to_str().expect("path to str"),
192- );*/
193-
194172 let path = obj_out. to_str ( ) . expect ( "path to str" ) ;
195173
196174 if fat_lto {
@@ -208,11 +186,7 @@ pub(crate) unsafe fn codegen(
208186 context. compile_to_file ( OutputKind :: Executable , & lto_path) ;
209187
210188 let context = Context :: default ( ) ; // TODO: might need to set some other flags from new_context.
211- //context.add_driver_option("-v");
212- //println!("*** Arch: {}", cgcx.target_arch);
213189 if cgcx. target_arch == "x86" || cgcx. target_arch == "x86_64" {
214- //println!("**** Added -masm=intel");
215- //context.add_command_line_option("-masm=intel");
216190 // NOTE: it seems we need to use add_driver_option instead of
217191 // add_command_line_option here because we use the LTO frontend via gcc.
218192 context. add_driver_option ( "-masm=intel" ) ;
@@ -295,31 +269,3 @@ pub(crate) fn save_temp_bitcode(
295269 llvm::LLVMWriteBitcodeToFile(llmod, cstr.as_ptr());
296270 }*/
297271}
298-
299- /*fn create_msvc_imps<'gcc>(cgcx: &CodegenContext<GccCodegenBackend>, _context: &Context<'gcc>) {
300- if !cgcx.msvc_imps_needed {
301- return;
302- }
303-
304- /*unsafe {
305- let ptr_ty = Type::ptr_llcx(llcx);
306- let globals = base::iter_globals(llmod)
307- .filter(|&val| {
308- llvm::get_linkage(val) == llvm::Linkage::ExternalLinkage
309- && llvm::LLVMIsDeclaration(val) == 0
310- })
311- .map(move |(val, name)| {
312- let mut imp_name = prefix.as_bytes().to_vec();
313- imp_name.extend(name);
314- let imp_name = CString::new(imp_name).unwrap();
315- (imp_name, val)
316- })
317- .collect::<Vec<_>>();
318-
319- for (imp_name, val) in globals {
320- let imp = llvm::LLVMAddGlobal(llmod, ptr_ty, imp_name.as_ptr());
321- llvm::LLVMSetInitializer(imp, val);
322- llvm::set_linkage(imp, llvm::Linkage::ExternalLinkage);
323- }
324- }*/
325- }*/
0 commit comments