Skip to content

Commit 28ccfad

Browse files
committed
Remove each_linked_rlib_for_lto from CodegenContext
1 parent ecab766 commit 28ccfad

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/back/lto.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct LtoData {
4949

5050
fn prepare_lto(
5151
cgcx: &CodegenContext<GccCodegenBackend>,
52+
each_linked_rlib_for_lto: &[PathBuf],
5253
dcx: DiagCtxtHandle<'_>,
5354
) -> Result<LtoData, FatalError> {
5455
let tmp_path = match tempdir() {
@@ -67,7 +68,7 @@ fn prepare_lto(
6768
// with either fat or thin LTO
6869
let mut upstream_modules = Vec::new();
6970
if cgcx.lto != Lto::ThinLocal {
70-
for &(_cnum, ref path) in cgcx.each_linked_rlib_for_lto.iter() {
71+
for path in each_linked_rlib_for_lto {
7172
let archive_data = unsafe {
7273
Mmap::map(File::open(path).expect("couldn't open rlib")).expect("couldn't map rlib")
7374
};
@@ -111,11 +112,12 @@ fn save_as_file(obj: &[u8], path: &Path) -> Result<(), LtoBitcodeFromRlib> {
111112
/// for further optimization.
112113
pub(crate) fn run_fat(
113114
cgcx: &CodegenContext<GccCodegenBackend>,
115+
each_linked_rlib_for_lto: &[PathBuf],
114116
modules: Vec<FatLtoInput<GccCodegenBackend>>,
115117
) -> Result<ModuleCodegen<GccContext>, FatalError> {
116118
let dcx = cgcx.create_dcx();
117119
let dcx = dcx.handle();
118-
let lto_data = prepare_lto(cgcx, dcx)?;
120+
let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx)?;
119121
/*let symbols_below_threshold =
120122
lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/
121123
fat_lto(
@@ -281,12 +283,13 @@ impl ModuleBufferMethods for ModuleBuffer {
281283
/// can simply be copied over from the incr. comp. cache.
282284
pub(crate) fn run_thin(
283285
cgcx: &CodegenContext<GccCodegenBackend>,
286+
each_linked_rlib_for_lto: &[PathBuf],
284287
modules: Vec<(String, ThinBuffer)>,
285288
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
286289
) -> Result<(Vec<ThinModule<GccCodegenBackend>>, Vec<WorkProduct>), FatalError> {
287290
let dcx = cgcx.create_dcx();
288291
let dcx = dcx.handle();
289-
let lto_data = prepare_lto(cgcx, dcx)?;
292+
let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx)?;
290293
if cgcx.opts.cg.linker_plugin_lto.enabled() {
291294
unreachable!(
292295
"We should never reach this case if the LTO step \

src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ mod type_of;
8181
use std::any::Any;
8282
use std::fmt::Debug;
8383
use std::ops::Deref;
84+
use std::path::PathBuf;
8485
#[cfg(not(feature = "master"))]
8586
use std::sync::atomic::AtomicBool;
8687
#[cfg(not(feature = "master"))]
@@ -360,24 +361,26 @@ impl WriteBackendMethods for GccCodegenBackend {
360361
cgcx: &CodegenContext<Self>,
361362
// FIXME(bjorn3): Limit LTO exports to these symbols
362363
_exported_symbols_for_lto: &[String],
364+
each_linked_rlib_for_lto: &[PathBuf],
363365
modules: Vec<FatLtoInput<Self>>,
364366
diff_fncs: Vec<AutoDiffItem>,
365367
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
366368
if !diff_fncs.is_empty() {
367369
unimplemented!();
368370
}
369371

370-
back::lto::run_fat(cgcx, modules)
372+
back::lto::run_fat(cgcx, each_linked_rlib_for_lto, modules)
371373
}
372374

373375
fn run_thin_lto(
374376
cgcx: &CodegenContext<Self>,
375377
// FIXME(bjorn3): Limit LTO exports to these symbols
376378
_exported_symbols_for_lto: &[String],
379+
each_linked_rlib_for_lto: &[PathBuf],
377380
modules: Vec<(String, Self::ThinBuffer)>,
378381
cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
379382
) -> Result<(Vec<ThinModule<Self>>, Vec<WorkProduct>), FatalError> {
380-
back::lto::run_thin(cgcx, modules, cached_modules)
383+
back::lto::run_thin(cgcx, each_linked_rlib_for_lto, modules, cached_modules)
381384
}
382385

383386
fn print_pass_timings(&self) {

0 commit comments

Comments
 (0)