Skip to content

Commit d4e5e1b

Browse files
nnethercotealexcrichton
authored andcommitted
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.
1 parent fd61d06 commit d4e5e1b

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;
@@ -478,10 +478,7 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
478478
let mut files = vec![];
479479

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

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

853839
assert_eq!(object.is_some(), module_config.emit_obj != EmitObj::None);
854-
assert_eq!(bytecode.is_some(), module_config.emit_bc);
855840

856841
Ok(WorkItemResult::Compiled(CompiledModule {
857842
name: module.name,
858843
kind: ModuleKind::Regular,
859844
object,
860-
bytecode,
845+
bytecode: None,
861846
}))
862847
}
863848

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)