@@ -31,14 +31,9 @@ pub(crate) unsafe fn codegen(
31
31
32
32
// NOTE: Only generate object files with GIMPLE when this environment variable is set for
33
33
// 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.
35
35
let fat_lto = env:: var ( "EMBED_LTO_BITCODE" ) . as_deref ( ) == Ok ( "1" ) ;
36
36
37
- /*if cgcx.msvc_imps_needed {
38
- println!("************************************************** Imps needed");
39
- create_msvc_imps(cgcx, context);
40
- }*/
41
-
42
37
let bc_out = cgcx. output_filenames . temp_path ( OutputType :: Bitcode , module_name) ;
43
38
let obj_out = cgcx. output_filenames . temp_path ( OutputType :: Object , module_name) ;
44
39
@@ -64,7 +59,7 @@ pub(crate) unsafe fn codegen(
64
59
) ;
65
60
context. add_command_line_option ( "-flto=auto" ) ;
66
61
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.
68
63
context. add_command_line_option ( "-ffat-lto-objects" ) ;
69
64
context. compile_to_file (
70
65
OutputKind :: ObjectFile ,
@@ -102,7 +97,7 @@ pub(crate) unsafe fn codegen(
102
97
}
103
98
104
99
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
106
101
// environment variable EMBED_LTO_BITCODE.
107
102
let _timer = cgcx. prof . generic_activity_with_arg (
108
103
"GCC_module_codegen_embed_bitcode" ,
@@ -111,12 +106,6 @@ pub(crate) unsafe fn codegen(
111
106
// TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
112
107
//embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
113
108
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
- }
120
109
// 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).
121
110
context. compile_to_file (
122
111
OutputKind :: ObjectFile ,
@@ -172,8 +161,6 @@ pub(crate) unsafe fn codegen(
172
161
// lto1: internal compiler error: decompressed stream: Destination buffer is too small
173
162
// TODO: since we do not do LTO when the linker is invoked anymore, perhaps
174
163
// the following flag is not necessary anymore.
175
- // TODO: also, perhaps compiling the gcc driver in the CI is not necessary
176
- // anymore.
177
164
context. add_driver_option ( "-fuse-linker-plugin" ) ;
178
165
}
179
166
@@ -182,15 +169,6 @@ pub(crate) unsafe fn codegen(
182
169
// /usr/bin/ld: cannot find -lgcc_s: No such file or directory
183
170
context. add_driver_option ( "-nostdlib" ) ;
184
171
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
-
194
172
let path = obj_out. to_str ( ) . expect ( "path to str" ) ;
195
173
196
174
if fat_lto {
@@ -208,11 +186,7 @@ pub(crate) unsafe fn codegen(
208
186
context. compile_to_file ( OutputKind :: Executable , & lto_path) ;
209
187
210
188
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);
213
189
if cgcx. target_arch == "x86" || cgcx. target_arch == "x86_64" {
214
- //println!("**** Added -masm=intel");
215
- //context.add_command_line_option("-masm=intel");
216
190
// NOTE: it seems we need to use add_driver_option instead of
217
191
// add_command_line_option here because we use the LTO frontend via gcc.
218
192
context. add_driver_option ( "-masm=intel" ) ;
@@ -295,31 +269,3 @@ pub(crate) fn save_temp_bitcode(
295
269
llvm::LLVMWriteBitcodeToFile(llmod, cstr.as_ptr());
296
270
}*/
297
271
}
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