Skip to content

Commit e85346e

Browse files
committed
Support symbols_below_threshold
1 parent f360e72 commit e85346e

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

build_system/build_sysroot/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ codegen-units = 10000
3535

3636
[profile.release]
3737
debug = "limited"
38-
#lto = "fat" # TODO(antoyo): re-enable when the failing LTO tests regarding proc-macros are fixed.
38+
lto = "fat" # TODO(antoyo): re-enable when the failing LTO tests regarding proc-macros are fixed.

src/back/lto.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ pub fn crate_type_allows_lto(crate_type: CrateType) -> bool {
5050
}
5151

5252
struct LtoData {
53-
// TODO(antoyo): use symbols_below_threshold.
54-
//symbols_below_threshold: Vec<String>,
53+
symbols_below_threshold: Vec<String>,
5554
upstream_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
5655
tmp_path: TempDir,
5756
}
@@ -156,7 +155,11 @@ fn prepare_lto(
156155
}
157156
}
158157

159-
Ok(LtoData { upstream_modules, tmp_path })
158+
Ok(LtoData {
159+
upstream_modules,
160+
symbols_below_threshold,
161+
tmp_path,
162+
})
160163
}
161164

162165
fn save_as_file(obj: &[u8], path: &Path) -> Result<(), LtoBitcodeFromRlib> {
@@ -175,16 +178,16 @@ pub(crate) fn run_fat(
175178
let dcx = cgcx.create_dcx();
176179
let dcx = dcx.handle();
177180
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<_>>();
180183
fat_lto(
181184
cgcx,
182185
dcx,
183186
modules,
184187
cached_modules,
185188
lto_data.upstream_modules,
186189
lto_data.tmp_path,
187-
//&lto_data.symbols_below_threshold,
190+
&lto_data.symbols_below_threshold,
188191
)
189192
}
190193

@@ -195,7 +198,7 @@ fn fat_lto(
195198
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
196199
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
197200
tmp_path: TempDir,
198-
//symbols_below_threshold: &[String],
201+
symbols_below_threshold: &[String],
199202
) -> Result<LtoModuleCodegen<GccCodegenBackend>, FatalError> {
200203
let _timer = cgcx.prof.generic_activity("GCC_fat_lto_build_monolithic_module");
201204
info!("going for a fat lto");
@@ -312,6 +315,11 @@ fn fat_lto(
312315
}
313316
save_temp_bitcode(cgcx, &module, "lto.input");
314317

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+
}
315323
// Internalize everything below threshold to help strip out more modules and such.
316324
/*unsafe {
317325
let ptr = symbols_below_threshold.as_ptr();

0 commit comments

Comments
 (0)