@@ -21,7 +21,7 @@ use std::fs::{self, File};
21
21
use std:: path:: { Path , PathBuf } ;
22
22
use std:: sync:: Arc ;
23
23
24
- use gccjit:: { Context , FnAttribute , FunctionType , GlobalKind , OutputKind } ;
24
+ use gccjit:: { Context , OutputKind } ;
25
25
use object:: read:: archive:: ArchiveFile ;
26
26
use rustc_codegen_ssa:: back:: lto:: { LtoModuleCodegen , SerializedModule , ThinModule , ThinShared } ;
27
27
use rustc_codegen_ssa:: back:: symbol_export;
@@ -50,7 +50,7 @@ pub fn crate_type_allows_lto(crate_type: CrateType) -> bool {
50
50
51
51
struct LtoData {
52
52
// TODO(antoyo): use symbols_below_threshold.
53
- symbols_below_threshold : Vec < String > ,
53
+ // symbols_below_threshold: Vec<String>,
54
54
upstream_modules : Vec < ( SerializedModule < ModuleBuffer > , CString ) > ,
55
55
tmp_path : TempDir ,
56
56
}
@@ -85,15 +85,12 @@ fn prepare_lto(
85
85
}
86
86
} ;
87
87
let exported_symbols = cgcx. exported_symbols . as_ref ( ) . expect ( "needs exported symbols for LTO" ) ;
88
- //println!("1. {:?}", exported_symbols);
89
88
let mut symbols_below_threshold = {
90
89
let _timer = cgcx. prof . generic_activity ( "GCC_lto_generate_symbols_below_threshold" ) ;
91
90
exported_symbols[ & LOCAL_CRATE ] . iter ( ) . filter_map ( symbol_filter) . collect :: < Vec < String > > ( )
92
91
} ;
93
92
info ! ( "{} symbols to preserve in this crate" , symbols_below_threshold. len( ) ) ;
94
93
95
- //println!("2. {:?}", symbols_below_threshold);
96
-
97
94
// If we're performing LTO for the entire crate graph, then for each of our
98
95
// upstream dependencies, find the corresponding rlib and load the bitcode
99
96
// from the archive.
@@ -122,7 +119,6 @@ fn prepare_lto(
122
119
for & ( cnum, ref path) in cgcx. each_linked_rlib_for_lto . iter ( ) {
123
120
let exported_symbols =
124
121
cgcx. exported_symbols . as_ref ( ) . expect ( "needs exported symbols for LTO" ) ;
125
- //println!("3. {:?}", exported_symbols);
126
122
{
127
123
let _timer = cgcx. prof . generic_activity ( "GCC_lto_generate_symbols_below_threshold" ) ;
128
124
symbols_below_threshold
@@ -159,12 +155,7 @@ fn prepare_lto(
159
155
}
160
156
}
161
157
162
- println ! ( "**** 4. {:?}" , symbols_below_threshold) ;
163
- Ok ( LtoData {
164
- symbols_below_threshold,
165
- upstream_modules,
166
- tmp_path,
167
- } )
158
+ Ok ( LtoData { upstream_modules, tmp_path } )
168
159
}
169
160
170
161
fn save_as_file ( obj : & [ u8 ] , path : & Path ) -> Result < ( ) , LtoBitcodeFromRlib > {
@@ -192,7 +183,7 @@ pub(crate) fn run_fat(
192
183
cached_modules,
193
184
lto_data. upstream_modules ,
194
185
lto_data. tmp_path ,
195
- & lto_data. symbols_below_threshold ,
186
+ // <o_data.symbols_below_threshold,
196
187
)
197
188
}
198
189
@@ -203,7 +194,7 @@ fn fat_lto(
203
194
cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > ,
204
195
mut serialized_modules : Vec < ( SerializedModule < ModuleBuffer > , CString ) > ,
205
196
tmp_path : TempDir ,
206
- symbols_below_threshold : & [ String ] ,
197
+ // symbols_below_threshold: &[String],
207
198
) -> Result < LtoModuleCodegen < GccCodegenBackend > , FatalError > {
208
199
let _timer = cgcx. prof . generic_activity ( "GCC_fat_lto_build_monolithic_module" ) ;
209
200
info ! ( "going for a fat lto" ) ;
@@ -328,14 +319,7 @@ fn fat_lto(
328
319
ptr as *const *const libc::c_char,
329
320
symbols_below_threshold.len() as libc::size_t,
330
321
);*/
331
- let int_type = module. module_llvm . context . new_type :: < i32 > ( ) ;
332
- for symbol in symbols_below_threshold {
333
- println ! ( "*** Keeping symbol: {}" , symbol) ;
334
- module. module_llvm . context . new_global ( None , GlobalKind :: Imported , int_type, symbol) ;
335
- }
336
- let void_type = module. module_llvm . context . new_type :: < ( ) > ( ) ;
337
- let func = module. module_llvm . context . new_function ( None , FunctionType :: Extern , void_type, & [ ] , "__rust_alloc" , false ) ;
338
- func. add_attribute ( FnAttribute :: Used ) ;
322
+
339
323
save_temp_bitcode ( cgcx, & module, "lto.after-restriction" ) ;
340
324
//}
341
325
}
@@ -385,7 +369,7 @@ pub(crate) fn run_thin(
385
369
lto_data. upstream_modules ,
386
370
lto_data. tmp_path ,
387
371
cached_modules,
388
- & lto_data. symbols_below_threshold ,
372
+ // <o_data.symbols_below_threshold,
389
373
)
390
374
}
391
375
@@ -436,10 +420,8 @@ fn thin_lto(
436
420
serialized_modules : Vec < ( SerializedModule < ModuleBuffer > , CString ) > ,
437
421
tmp_path : TempDir ,
438
422
cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > ,
439
- symbols_below_threshold : & [ String ] ,
423
+ //_symbols_below_threshold : &[String],
440
424
) -> Result < ( Vec < LtoModuleCodegen < GccCodegenBackend > > , Vec < WorkProduct > ) , FatalError > {
441
- println ! ( "********* Thin LTO" ) ;
442
-
443
425
let _timer = cgcx. prof . generic_activity ( "LLVM_thin_lto_global_analysis" ) ;
444
426
info ! ( "going for that thin, thin LTO" ) ;
445
427
@@ -509,12 +491,6 @@ fn thin_lto(
509
491
}
510
492
}
511
493
512
- /*for symbol in symbols_below_threshold {
513
- module.module_llvm.context.new_global(symbol);
514
- }*/
515
-
516
- println ! ( "**** Name: {:?}\n ******" , name) ;
517
-
518
494
serialized. push ( module) ;
519
495
module_names. push ( name) ;
520
496
}
0 commit comments