@@ -50,8 +50,7 @@ pub fn crate_type_allows_lto(crate_type: CrateType) -> bool {
50
50
}
51
51
52
52
struct LtoData {
53
- // TODO(antoyo): use symbols_below_threshold.
54
- //symbols_below_threshold: Vec<String>,
53
+ symbols_below_threshold : Vec < String > ,
55
54
upstream_modules : Vec < ( SerializedModule < ModuleBuffer > , CString ) > ,
56
55
tmp_path : TempDir ,
57
56
}
@@ -156,7 +155,11 @@ fn prepare_lto(
156
155
}
157
156
}
158
157
159
- Ok ( LtoData { upstream_modules, tmp_path } )
158
+ Ok ( LtoData {
159
+ upstream_modules,
160
+ symbols_below_threshold,
161
+ tmp_path,
162
+ } )
160
163
}
161
164
162
165
fn save_as_file ( obj : & [ u8 ] , path : & Path ) -> Result < ( ) , LtoBitcodeFromRlib > {
@@ -175,16 +178,16 @@ pub(crate) fn run_fat(
175
178
let dcx = cgcx. create_dcx ( ) ;
176
179
let dcx = dcx. handle ( ) ;
177
180
let lto_data = prepare_lto ( cgcx, dcx) ?;
178
- /* let symbols_below_threshold =
179
- lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/
181
+ let symbols_below_threshold =
182
+ lto_data. symbols_below_threshold . iter ( ) . map ( |c| c. as_ptr ( ) ) . collect :: < Vec < _ > > ( ) ;
180
183
fat_lto (
181
184
cgcx,
182
185
dcx,
183
186
modules,
184
187
cached_modules,
185
188
lto_data. upstream_modules ,
186
189
lto_data. tmp_path ,
187
- // <o_data.symbols_below_threshold,
190
+ & lto_data. symbols_below_threshold ,
188
191
)
189
192
}
190
193
@@ -195,7 +198,7 @@ fn fat_lto(
195
198
cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > ,
196
199
mut serialized_modules : Vec < ( SerializedModule < ModuleBuffer > , CString ) > ,
197
200
tmp_path : TempDir ,
198
- // symbols_below_threshold: &[String],
201
+ symbols_below_threshold : & [ String ] ,
199
202
) -> Result < LtoModuleCodegen < GccCodegenBackend > , FatalError > {
200
203
let _timer = cgcx. prof . generic_activity ( "GCC_fat_lto_build_monolithic_module" ) ;
201
204
info ! ( "going for a fat lto" ) ;
@@ -312,6 +315,11 @@ fn fat_lto(
312
315
}
313
316
save_temp_bitcode ( cgcx, & module, "lto.input" ) ;
314
317
318
+ for symbol in symbols_below_threshold {
319
+ println ! ( "Internalize {}" , symbol) ;
320
+ // TODO: Create a function that is always_inline and that calls the symbol here (e.g.
321
+ // main)?
322
+ }
315
323
// Internalize everything below threshold to help strip out more modules and such.
316
324
/*unsafe {
317
325
let ptr = symbols_below_threshold.as_ptr();
0 commit comments