Skip to content

Commit 649b632

Browse files
committedMay 4, 2020
Auto merge of rust-lang#71754 - alexcrichton:no-bitcode-in-cache, r=nnethercote
Don't copy bytecode files into the incr. comp. cache. It's no longer necessary now that bitcode is embedded into object files. This change meant that `WorkProductFileKind::Bytecode` is no longer necessary, which means that type is no longer necessary, which allowed several places in the code to become simpler. This commit was written by @nnethercote in rust-lang#70458 but that didn't land. In the meantime though we managed to land it in rust-lang#71528 and that doesn't seem to be causing too many fires, so I'm re-sending this patch!
2 parents 6318d24 + d4e5e1b commit 649b632

File tree

7 files changed

+19
-45
lines changed

7 files changed

+19
-45
lines changed
 

‎src/librustc_codegen_ssa/back/write.rs

+6-21
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
2323
use rustc_incremental::{
2424
copy_cgu_workproducts_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess,
2525
};
26-
use rustc_middle::dep_graph::{WorkProduct, WorkProductFileKind, WorkProductId};
26+
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
2727
use rustc_middle::middle::cstore::EncodedMetadata;
2828
use rustc_middle::middle::exported_symbols::SymbolExportLevel;
2929
use rustc_middle::ty::TyCtxt;
@@ -477,10 +477,7 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
477477
let mut files = vec![];
478478

479479
if let Some(ref path) = module.object {
480-
files.push((WorkProductFileKind::Object, path.clone()));
481-
}
482-
if let Some(ref path) = module.bytecode {
483-
files.push((WorkProductFileKind::Bytecode, path.clone()));
480+
files.push(path.clone());
484481
}
485482

486483
if let Some((id, product)) =
@@ -817,20 +814,9 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
817814
) -> Result<WorkItemResult<B>, FatalError> {
818815
let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();
819816
let mut object = None;
820-
let mut bytecode = None;
821-
for (kind, saved_file) in &module.source.saved_files {
822-
let obj_out = match kind {
823-
WorkProductFileKind::Object => {
824-
let path = cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name));
825-
object = Some(path.clone());
826-
path
827-
}
828-
WorkProductFileKind::Bytecode => {
829-
let path = cgcx.output_filenames.temp_path(OutputType::Bitcode, Some(&module.name));
830-
bytecode = Some(path.clone());
831-
path
832-
}
833-
};
817+
for saved_file in &module.source.saved_files {
818+
let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name));
819+
object = Some(obj_out.clone());
834820
let source_file = in_incr_comp_dir(&incr_comp_session_dir, &saved_file);
835821
debug!(
836822
"copying pre-existing module `{}` from {:?} to {}",
@@ -850,13 +836,12 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
850836
}
851837

852838
assert_eq!(object.is_some(), module_config.emit_obj != EmitObj::None);
853-
assert_eq!(bytecode.is_some(), module_config.emit_bc);
854839

855840
Ok(WorkItemResult::Compiled(CompiledModule {
856841
name: module.name,
857842
kind: ModuleKind::Regular,
858843
object,
859-
bytecode,
844+
bytecode: None,
860845
}))
861846
}
862847

‎src/librustc_incremental/persist/load.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
134134

135135
for swp in work_products {
136136
let mut all_files_exist = true;
137-
for &(_, ref file_name) in swp.work_product.saved_files.iter() {
137+
for file_name in swp.work_product.saved_files.iter() {
138138
let path = in_incr_comp_dir_sess(sess, file_name);
139139
if !path.exists() {
140140
all_files_exist = false;

‎src/librustc_incremental/persist/save.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ pub fn save_work_product_index(
7474
if !new_work_products.contains_key(id) {
7575
work_product::delete_workproduct_files(sess, wp);
7676
debug_assert!(
77-
wp.saved_files.iter().all(|&(_, ref file_name)| {
78-
!in_incr_comp_dir_sess(sess, file_name).exists()
79-
})
77+
wp.saved_files
78+
.iter()
79+
.all(|file_name| { !in_incr_comp_dir_sess(sess, file_name).exists() })
8080
);
8181
}
8282
}
@@ -85,7 +85,7 @@ pub fn save_work_product_index(
8585
debug_assert!({
8686
new_work_products
8787
.iter()
88-
.flat_map(|(_, wp)| wp.saved_files.iter().map(|&(_, ref name)| name))
88+
.flat_map(|(_, wp)| wp.saved_files.iter())
8989
.map(|name| in_incr_comp_dir_sess(sess, name))
9090
.all(|path| path.exists())
9191
});

‎src/librustc_incremental/persist/work_product.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,26 @@
22
33
use crate::persist::fs::*;
44
use rustc_fs_util::link_or_copy;
5-
use rustc_middle::dep_graph::{WorkProduct, WorkProductFileKind, WorkProductId};
5+
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
66
use rustc_session::Session;
77
use std::fs as std_fs;
88
use std::path::PathBuf;
99

1010
pub fn copy_cgu_workproducts_to_incr_comp_cache_dir(
1111
sess: &Session,
1212
cgu_name: &str,
13-
files: &[(WorkProductFileKind, PathBuf)],
13+
files: &[PathBuf],
1414
) -> Option<(WorkProductId, WorkProduct)> {
1515
debug!("copy_cgu_workproducts_to_incr_comp_cache_dir({:?},{:?})", cgu_name, files);
1616
sess.opts.incremental.as_ref()?;
1717

1818
let saved_files = files
1919
.iter()
20-
.map(|&(kind, ref path)| {
21-
let extension = match kind {
22-
WorkProductFileKind::Object => "o",
23-
WorkProductFileKind::Bytecode => "bc",
24-
};
25-
let file_name = format!("{}.{}", cgu_name, extension);
20+
.map(|path| {
21+
let file_name = format!("{}.o", cgu_name);
2622
let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
2723
match link_or_copy(path, &path_in_incr_dir) {
28-
Ok(_) => Some((kind, file_name)),
24+
Ok(_) => Some(file_name),
2925
Err(err) => {
3026
sess.warn(&format!(
3127
"error copying object file `{}` \
@@ -47,7 +43,7 @@ pub fn copy_cgu_workproducts_to_incr_comp_cache_dir(
4743
}
4844

4945
pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) {
50-
for &(_, ref file_name) in &work_product.saved_files {
46+
for file_name in &work_product.saved_files {
5147
let path = in_incr_comp_dir_sess(sess, file_name);
5248
match std_fs::remove_file(&path) {
5349
Ok(()) => {}

‎src/librustc_middle/dep_graph/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod dep_node;
1212
pub(crate) use rustc_query_system::dep_graph::DepNodeParams;
1313
pub use rustc_query_system::dep_graph::{
1414
debug, hash_result, DepContext, DepNodeColor, DepNodeIndex, SerializedDepNodeIndex,
15-
WorkProduct, WorkProductFileKind, WorkProductId,
15+
WorkProduct, WorkProductId,
1616
};
1717

1818
pub use dep_node::{label_strs, DepConstructor, DepKind, DepNode, DepNodeExt};

‎src/librustc_query_system/dep_graph/graph.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -861,13 +861,7 @@ impl<K: DepKind> DepGraph<K> {
861861
pub struct WorkProduct {
862862
pub cgu_name: String,
863863
/// Saved files associated with this CGU.
864-
pub saved_files: Vec<(WorkProductFileKind, String)>,
865-
}
866-
867-
#[derive(Clone, Copy, Debug, RustcEncodable, RustcDecodable, PartialEq)]
868-
pub enum WorkProductFileKind {
869-
Object,
870-
Bytecode,
864+
pub saved_files: Vec<String>,
871865
}
872866

873867
#[derive(Clone)]

‎src/librustc_query_system/dep_graph/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ mod query;
66
mod serialized;
77

88
pub use dep_node::{DepNode, DepNodeParams, WorkProductId};
9-
pub use graph::WorkProductFileKind;
109
pub use graph::{hash_result, DepGraph, DepNodeColor, DepNodeIndex, TaskDeps, WorkProduct};
1110
pub use prev::PreviousDepGraph;
1211
pub use query::DepGraphQuery;

0 commit comments

Comments
 (0)
Please sign in to comment.