@@ -65,13 +65,18 @@ pub(crate) unsafe fn codegen(
65
65
"GCC_module_codegen_emit_bitcode" ,
66
66
& * module. name ,
67
67
) ;
68
+ println ! ( "Adding -flto for {}" , bc_out. to_str( ) . unwrap( ) ) ;
68
69
context. add_command_line_option ( "-flto=auto" ) ;
69
70
context. add_command_line_option ( "-flto-partition=one" ) ;
71
+ context. add_driver_option ( "-flto=auto" ) ;
72
+ context. add_driver_option ( "-flto-partition=one" ) ;
73
+ context. add_command_line_option ( "-fno-fat-lto-objects" ) ;
74
+ context. add_driver_option ( "-fno-fat-lto-objects" ) ;
70
75
// FIXME FIXME FIXME: it seems that uncommenting "ADD_ARG ("-fno-use-linker-plugin")" in libgccjit
71
76
// make the test fail (undefined symbol main).
72
77
// TODO: Perhaps we're not sending this flag somewhere?
73
78
context. add_command_line_option ( "-fno-use-linker-plugin" ) ;
74
- context. add_driver_option ( "-fno-use-linker-plugin" ) ;
79
+ // context.add_driver_option("-fno-use-linker-plugin");
75
80
// TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only.
76
81
context. add_command_line_option ( "-ffat-lto-objects" ) ;
77
82
context. compile_to_file (
@@ -88,10 +93,15 @@ pub(crate) unsafe fn codegen(
88
93
// TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
89
94
//embed_bitcode(cgcx, llcx, llmod, &config.bc_cmdline, data);
90
95
96
+ println ! ( "Adding -flto for {}" , bc_out. to_str( ) . unwrap( ) ) ;
91
97
context. add_command_line_option ( "-flto=auto" ) ;
92
98
context. add_command_line_option ( "-flto-partition=one" ) ;
99
+ context. add_driver_option ( "-flto=auto" ) ;
100
+ context. add_driver_option ( "-flto-partition=one" ) ;
101
+ context. add_command_line_option ( "-fno-fat-lto-objects" ) ;
102
+ context. add_driver_option ( "-fno-fat-lto-objects" ) ;
93
103
context. add_command_line_option ( "-fno-use-linker-plugin" ) ;
94
- context. add_driver_option ( "-fno-use-linker-plugin" ) ;
104
+ // context.add_driver_option("-fno-use-linker-plugin");
95
105
context. add_command_line_option ( "-ffat-lto-objects" ) ;
96
106
// 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).
97
107
context. compile_to_file (
@@ -179,15 +189,20 @@ pub(crate) unsafe fn codegen(
179
189
if fat_lto {
180
190
context. add_command_line_option ( "-flto=auto" ) ;
181
191
context. add_command_line_option ( "-flto-partition=one" ) ;
192
+ context. add_driver_option ( "-flto=auto" ) ;
193
+ context. add_driver_option ( "-flto-partition=one" ) ;
194
+ context. add_command_line_option ( "-fno-fat-lto-objects" ) ;
195
+ context. add_driver_option ( "-fno-fat-lto-objects" ) ;
182
196
//context.add_command_line_option("-ffat-lto-objects");
183
197
context. add_command_line_option ( "-fno-use-linker-plugin" ) ;
184
- context. add_driver_option ( "-fno-use-linker-plugin" ) ;
198
+ // context.add_driver_option("-fno-use-linker-plugin");
185
199
186
- // FIXME FIXME FIXME :
200
+ // FIXME:
187
201
// /usr/bin/ld: warning: incremental linking of LTO and non-LTO objects; using -flinker-output=nolto-rel which will bypass whole program optimization
188
- // ====> So I'm probably missing -flto somewhere.
202
+ // => So I'm probably missing -flto somewhere.
203
+ // ====> That was caused because I didn't build the sysroot with LTO.
189
204
190
- println ! ( "**** Adding -flto to {:?}" , obj_out. to_str( ) . expect( "path to str" ) ) ;
205
+ println ! ( "Adding -flto to {:?}" , obj_out. to_str( ) . expect( "path to str" ) ) ;
191
206
192
207
// FIXME: the problem is probably that the code is only in GIMPLE IR while
193
208
// we would want to get the optimized asm done from LTO.
@@ -221,8 +236,14 @@ pub(crate) unsafe fn codegen(
221
236
println ! ( "****************************************************************************************************" ) ;
222
237
223
238
let context = Context :: default ( ) ;
239
+ context. add_command_line_option ( "-flto=auto" ) ;
240
+ context. add_command_line_option ( "-flto-partition=one" ) ;
241
+ context. add_driver_option ( "-flto=auto" ) ;
242
+ context. add_driver_option ( "-flto-partition=one" ) ;
243
+ context. add_command_line_option ( "-fno-fat-lto-objects" ) ;
244
+ context. add_driver_option ( "-fno-fat-lto-objects" ) ;
224
245
context. add_command_line_option ( "-fno-use-linker-plugin" ) ;
225
- context. add_driver_option ( "-fno-use-linker-plugin" ) ;
246
+ // context.add_driver_option("-fno-use-linker-plugin");
226
247
if cgcx. target_arch == "x86" || cgcx. target_arch == "x86_64" {
227
248
// NOTE: it seems we need to use add_driver_option instead of
228
249
// add_command_line_option here because we use the LTO frontend via gcc.
0 commit comments