@@ -21,7 +21,7 @@ use std::fs::{self, File};
2121use std:: path:: { Path , PathBuf } ;
2222use std:: sync:: Arc ;
2323
24- use gccjit:: { Context , FnAttribute , FunctionType , GlobalKind , OutputKind } ;
24+ use gccjit:: { Context , OutputKind } ;
2525use object:: read:: archive:: ArchiveFile ;
2626use rustc_codegen_ssa:: back:: lto:: { LtoModuleCodegen , SerializedModule , ThinModule , ThinShared } ;
2727use rustc_codegen_ssa:: back:: symbol_export;
@@ -50,7 +50,7 @@ pub fn crate_type_allows_lto(crate_type: CrateType) -> bool {
5050
5151struct LtoData {
5252 // TODO(antoyo): use symbols_below_threshold.
53- symbols_below_threshold : Vec < String > ,
53+ // symbols_below_threshold: Vec<String>,
5454 upstream_modules : Vec < ( SerializedModule < ModuleBuffer > , CString ) > ,
5555 tmp_path : TempDir ,
5656}
@@ -85,15 +85,12 @@ fn prepare_lto(
8585 }
8686 } ;
8787 let exported_symbols = cgcx. exported_symbols . as_ref ( ) . expect ( "needs exported symbols for LTO" ) ;
88- //println!("1. {:?}", exported_symbols);
8988 let mut symbols_below_threshold = {
9089 let _timer = cgcx. prof . generic_activity ( "GCC_lto_generate_symbols_below_threshold" ) ;
9190 exported_symbols[ & LOCAL_CRATE ] . iter ( ) . filter_map ( symbol_filter) . collect :: < Vec < String > > ( )
9291 } ;
9392 info ! ( "{} symbols to preserve in this crate" , symbols_below_threshold. len( ) ) ;
9493
95- //println!("2. {:?}", symbols_below_threshold);
96-
9794 // If we're performing LTO for the entire crate graph, then for each of our
9895 // upstream dependencies, find the corresponding rlib and load the bitcode
9996 // from the archive.
@@ -122,7 +119,6 @@ fn prepare_lto(
122119 for & ( cnum, ref path) in cgcx. each_linked_rlib_for_lto . iter ( ) {
123120 let exported_symbols =
124121 cgcx. exported_symbols . as_ref ( ) . expect ( "needs exported symbols for LTO" ) ;
125- //println!("3. {:?}", exported_symbols);
126122 {
127123 let _timer = cgcx. prof . generic_activity ( "GCC_lto_generate_symbols_below_threshold" ) ;
128124 symbols_below_threshold
@@ -159,12 +155,7 @@ fn prepare_lto(
159155 }
160156 }
161157
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 } )
168159}
169160
170161fn save_as_file ( obj : & [ u8 ] , path : & Path ) -> Result < ( ) , LtoBitcodeFromRlib > {
@@ -192,7 +183,7 @@ pub(crate) fn run_fat(
192183 cached_modules,
193184 lto_data. upstream_modules ,
194185 lto_data. tmp_path ,
195- & lto_data. symbols_below_threshold ,
186+ // <o_data.symbols_below_threshold,
196187 )
197188}
198189
@@ -203,7 +194,7 @@ fn fat_lto(
203194 cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > ,
204195 mut serialized_modules : Vec < ( SerializedModule < ModuleBuffer > , CString ) > ,
205196 tmp_path : TempDir ,
206- symbols_below_threshold : & [ String ] ,
197+ // symbols_below_threshold: &[String],
207198) -> Result < LtoModuleCodegen < GccCodegenBackend > , FatalError > {
208199 let _timer = cgcx. prof . generic_activity ( "GCC_fat_lto_build_monolithic_module" ) ;
209200 info ! ( "going for a fat lto" ) ;
@@ -328,14 +319,7 @@ fn fat_lto(
328319 ptr as *const *const libc::c_char,
329320 symbols_below_threshold.len() as libc::size_t,
330321 );*/
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+
339323 save_temp_bitcode ( cgcx, & module, "lto.after-restriction" ) ;
340324 //}
341325 }
@@ -385,7 +369,7 @@ pub(crate) fn run_thin(
385369 lto_data. upstream_modules ,
386370 lto_data. tmp_path ,
387371 cached_modules,
388- & lto_data. symbols_below_threshold ,
372+ // <o_data.symbols_below_threshold,
389373 )
390374}
391375
@@ -436,10 +420,8 @@ fn thin_lto(
436420 serialized_modules : Vec < ( SerializedModule < ModuleBuffer > , CString ) > ,
437421 tmp_path : TempDir ,
438422 cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > ,
439- symbols_below_threshold : & [ String ] ,
423+ //_symbols_below_threshold : &[String],
440424) -> Result < ( Vec < LtoModuleCodegen < GccCodegenBackend > > , Vec < WorkProduct > ) , FatalError > {
441- println ! ( "********* Thin LTO" ) ;
442-
443425 let _timer = cgcx. prof . generic_activity ( "LLVM_thin_lto_global_analysis" ) ;
444426 info ! ( "going for that thin, thin LTO" ) ;
445427
@@ -509,12 +491,6 @@ fn thin_lto(
509491 }
510492 }
511493
512- /*for symbol in symbols_below_threshold {
513- module.module_llvm.context.new_global(symbol);
514- }*/
515-
516- println ! ( "**** Name: {:?}\n ******" , name) ;
517-
518494 serialized. push ( module) ;
519495 module_names. push ( name) ;
520496 }
0 commit comments