Skip to content

Commit 5c0110f

Browse files
Revert "Persist ThinLTO import data in incr. comp. session directory."
This reverts commit 8dc7ddb.
1 parent 6064efe commit 5c0110f

File tree

5 files changed

+4
-107
lines changed

5 files changed

+4
-107
lines changed

src/librustc_codegen_llvm/back/lto.rs

+2-81
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,10 @@ use {ModuleCodegen, ModuleLlvm, ModuleKind, ModuleSource};
2727
use libc;
2828

2929
use std::ffi::{CString, CStr};
30-
use std::fs::File;
31-
use std::io;
32-
use std::mem;
33-
use std::path::Path;
3430
use std::ptr;
3531
use std::slice;
3632
use std::sync::Arc;
3733

38-
pub const THIN_LTO_IMPORTS_INCR_COMP_FILE_NAME: &str = "thin-lto-imports.bin";
39-
4034
pub fn crate_type_allows_lto(crate_type: config::CrateType) -> bool {
4135
match crate_type {
4236
config::CrateTypeExecutable |
@@ -200,7 +194,7 @@ pub(crate) fn run(cgcx: &CodegenContext,
200194
}
201195
Lto::Thin |
202196
Lto::ThinLocal => {
203-
thin_lto(cgcx, &diag_handler, modules, upstream_modules, &arr, timeline)
197+
thin_lto(&diag_handler, modules, upstream_modules, &arr, timeline)
204198
}
205199
Lto::No => unreachable!(),
206200
}
@@ -353,8 +347,7 @@ impl Drop for Linker {
353347
/// calculating the *index* for ThinLTO. This index will then be shared amongst
354348
/// all of the `LtoModuleCodegen` units returned below and destroyed once
355349
/// they all go out of scope.
356-
fn thin_lto(cgcx: &CodegenContext,
357-
diag_handler: &Handler,
350+
fn thin_lto(diag_handler: &Handler,
358351
modules: Vec<ModuleCodegen>,
359352
serialized_modules: Vec<(SerializedModule, CString)>,
360353
symbol_white_list: &[*const libc::c_char],
@@ -432,18 +425,6 @@ fn thin_lto(cgcx: &CodegenContext,
432425
let msg = format!("failed to prepare thin LTO context");
433426
return Err(write::llvm_err(&diag_handler, msg))
434427
}
435-
436-
// Save the ThinLTO import information for incremental compilation.
437-
if let Some(ref incr_comp_session_dir) = cgcx.incr_comp_session_dir {
438-
let path = incr_comp_session_dir.join(THIN_LTO_IMPORTS_INCR_COMP_FILE_NAME);
439-
let imports = ThinLTOImports::from_thin_lto_data(data);
440-
if let Err(err) = imports.save_to_file(&path) {
441-
let msg = format!("Error while writing ThinLTO import data: {}",
442-
err);
443-
return Err(write::llvm_err(&diag_handler, msg));
444-
}
445-
}
446-
447428
let data = ThinData(data);
448429
info!("thin LTO data created");
449430
timeline.record("data");
@@ -806,12 +787,6 @@ pub struct ThinLTOImports {
806787

807788
impl ThinLTOImports {
808789

809-
pub fn new_empty() -> ThinLTOImports {
810-
ThinLTOImports {
811-
imports: FxHashMap(),
812-
}
813-
}
814-
815790
/// Load the ThinLTO import map from ThinLTOData.
816791
unsafe fn from_thin_lto_data(data: *const llvm::ThinLTOData) -> ThinLTOImports {
817792
let raw_data: *const llvm::ThinLTOModuleImports =
@@ -867,58 +842,4 @@ impl ThinLTOImports {
867842
imports
868843
}
869844
}
870-
871-
pub fn save_to_file(&self, path: &Path) -> io::Result<()> {
872-
use std::io::Write;
873-
874-
let file = File::create(path)?;
875-
let mut writer = io::BufWriter::new(file);
876-
877-
for (importing_module_name, imported_modules) in &self.imports {
878-
writeln!(writer, "{}", importing_module_name)?;
879-
880-
for imported_module in imported_modules {
881-
writeln!(writer, " {}", imported_module)?;
882-
}
883-
884-
writeln!(writer)?;
885-
}
886-
887-
Ok(())
888-
}
889-
890-
pub fn load_from_file(path: &Path) -> io::Result<ThinLTOImports> {
891-
use std::io::BufRead;
892-
893-
let mut imports = FxHashMap();
894-
let mut current_module = None;
895-
let mut current_imports = vec![];
896-
897-
let file = File::open(path)?;
898-
899-
for line in io::BufReader::new(file).lines() {
900-
let line = line?;
901-
902-
if line.is_empty() {
903-
let importing_module = current_module
904-
.take()
905-
.expect("Importing module not set");
906-
907-
imports.insert(importing_module,
908-
mem::replace(&mut current_imports, vec![]));
909-
} else if line.starts_with(" ") {
910-
// This is an imported module
911-
assert_ne!(current_module, None);
912-
current_imports.push(line.trim().to_string());
913-
} else {
914-
// This is the beginning of a new module
915-
assert_eq!(current_module, None);
916-
current_module = Some(line.trim().to_string());
917-
}
918-
}
919-
920-
Ok(ThinLTOImports {
921-
imports
922-
})
923-
}
924845
}

src/librustc_codegen_llvm/base.rs

+1-23
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use super::ModuleCodegen;
2929
use super::ModuleKind;
3030

3131
use abi;
32-
use back::{link, lto};
32+
use back::link;
3333
use back::write::{self, OngoingCodegen, create_target_machine};
3434
use llvm::{ContextRef, ModuleRef, ValueRef, Vector, get_param};
3535
use llvm;
@@ -1370,27 +1370,6 @@ mod temp_stable_hash_impls {
13701370
}
13711371
}
13721372

1373-
#[allow(unused)]
1374-
fn load_thin_lto_imports(sess: &Session) -> lto::ThinLTOImports {
1375-
let path = rustc_incremental::in_incr_comp_dir_sess(
1376-
sess,
1377-
lto::THIN_LTO_IMPORTS_INCR_COMP_FILE_NAME
1378-
);
1379-
1380-
if !path.exists() {
1381-
return lto::ThinLTOImports::new_empty();
1382-
}
1383-
1384-
match lto::ThinLTOImports::load_from_file(&path) {
1385-
Ok(imports) => imports,
1386-
Err(e) => {
1387-
let msg = format!("Error while trying to load ThinLTO import data \
1388-
for incremental compilation: {}", e);
1389-
sess.fatal(&msg)
1390-
}
1391-
}
1392-
}
1393-
13941373
pub fn define_custom_section(cx: &CodegenCx, def_id: DefId) {
13951374
use rustc::mir::interpret::GlobalId;
13961375

@@ -1429,4 +1408,3 @@ pub fn define_custom_section(cx: &CodegenCx, def_id: DefId) {
14291408
);
14301409
}
14311410
}
1432-

src/librustc_codegen_llvm/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ mod back {
9090
mod command;
9191
pub mod linker;
9292
pub mod link;
93-
pub mod lto;
93+
mod lto;
9494
pub mod symbol_export;
9595
pub mod write;
9696
mod rpath;

src/librustc_incremental/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub use persist::copy_cgu_workproducts_to_incr_comp_cache_dir;
4444
pub use persist::save_dep_graph;
4545
pub use persist::save_work_product_index;
4646
pub use persist::in_incr_comp_dir;
47-
pub use persist::in_incr_comp_dir_sess;
4847
pub use persist::prepare_session_directory;
4948
pub use persist::finalize_session_directory;
5049
pub use persist::delete_workproduct_files;

src/librustc_incremental/persist/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ mod file_format;
2323
pub use self::fs::finalize_session_directory;
2424
pub use self::fs::garbage_collect_session_directories;
2525
pub use self::fs::in_incr_comp_dir;
26-
pub use self::fs::in_incr_comp_dir_sess;
2726
pub use self::fs::prepare_session_directory;
2827
pub use self::load::dep_graph_tcx_init;
2928
pub use self::load::load_dep_graph;

0 commit comments

Comments
 (0)