mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
Make saved_file field of WorkProduct non-optional
A WorkProduct without a saved file is useless
This commit is contained in:
parent
906b85157c
commit
e16c3b4a44
@ -80,13 +80,9 @@ fn reuse_workproduct_for_cgu(
|
|||||||
cgu: &CodegenUnit<'_>,
|
cgu: &CodegenUnit<'_>,
|
||||||
work_products: &mut FxHashMap<WorkProductId, WorkProduct>,
|
work_products: &mut FxHashMap<WorkProductId, WorkProduct>,
|
||||||
) -> CompiledModule {
|
) -> CompiledModule {
|
||||||
let mut object = None;
|
|
||||||
let work_product = cgu.previous_work_product(tcx);
|
let work_product = cgu.previous_work_product(tcx);
|
||||||
if let Some(saved_file) = &work_product.saved_file {
|
let obj_out = tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu.name().as_str()));
|
||||||
let obj_out =
|
let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &work_product.saved_file);
|
||||||
tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu.name().as_str()));
|
|
||||||
object = Some(obj_out.clone());
|
|
||||||
let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &saved_file);
|
|
||||||
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
|
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
|
||||||
tcx.sess.err(&format!(
|
tcx.sess.err(&format!(
|
||||||
"unable to copy {} to {}: {}",
|
"unable to copy {} to {}: {}",
|
||||||
@ -95,14 +91,13 @@ fn reuse_workproduct_for_cgu(
|
|||||||
err
|
err
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
work_products.insert(cgu.work_product_id(), work_product);
|
work_products.insert(cgu.work_product_id(), work_product);
|
||||||
|
|
||||||
CompiledModule {
|
CompiledModule {
|
||||||
name: cgu.name().to_string(),
|
name: cgu.name().to_string(),
|
||||||
kind: ModuleKind::Regular,
|
kind: ModuleKind::Regular,
|
||||||
object,
|
object: Some(obj_out),
|
||||||
dwarf_object: None,
|
dwarf_object: None,
|
||||||
bytecode: None,
|
bytecode: None,
|
||||||
}
|
}
|
||||||
|
@ -853,12 +853,11 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
|
|||||||
module: CachedModuleCodegen,
|
module: CachedModuleCodegen,
|
||||||
module_config: &ModuleConfig,
|
module_config: &ModuleConfig,
|
||||||
) -> WorkItemResult<B> {
|
) -> WorkItemResult<B> {
|
||||||
|
assert!(module_config.emit_obj != EmitObj::None);
|
||||||
|
|
||||||
let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();
|
let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();
|
||||||
let mut object = None;
|
|
||||||
if let Some(saved_file) = module.source.saved_file {
|
|
||||||
let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name));
|
let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name));
|
||||||
object = Some(obj_out.clone());
|
let source_file = in_incr_comp_dir(&incr_comp_session_dir, &module.source.saved_file);
|
||||||
let source_file = in_incr_comp_dir(&incr_comp_session_dir, &saved_file);
|
|
||||||
debug!(
|
debug!(
|
||||||
"copying pre-existing module `{}` from {:?} to {}",
|
"copying pre-existing module `{}` from {:?} to {}",
|
||||||
module.name,
|
module.name,
|
||||||
@ -874,14 +873,11 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
|
|||||||
err
|
err
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
assert_eq!(object.is_some(), module_config.emit_obj != EmitObj::None);
|
|
||||||
|
|
||||||
WorkItemResult::Compiled(CompiledModule {
|
WorkItemResult::Compiled(CompiledModule {
|
||||||
name: module.name,
|
name: module.name,
|
||||||
kind: ModuleKind::Regular,
|
kind: ModuleKind::Regular,
|
||||||
object,
|
object: Some(obj_out),
|
||||||
dwarf_object: None,
|
dwarf_object: None,
|
||||||
bytecode: None,
|
bytecode: None,
|
||||||
})
|
})
|
||||||
|
@ -162,8 +162,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
|
|||||||
|
|
||||||
for swp in work_products {
|
for swp in work_products {
|
||||||
let mut all_files_exist = true;
|
let mut all_files_exist = true;
|
||||||
if let Some(ref file_name) = swp.work_product.saved_file {
|
let path = in_incr_comp_dir_sess(sess, &swp.work_product.saved_file);
|
||||||
let path = in_incr_comp_dir_sess(sess, file_name);
|
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
all_files_exist = false;
|
all_files_exist = false;
|
||||||
|
|
||||||
@ -175,7 +174,6 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if all_files_exist {
|
if all_files_exist {
|
||||||
debug!("reconcile_work_products: all files for {:?} exist", swp);
|
debug!("reconcile_work_products: all files for {:?} exist", swp);
|
||||||
|
@ -107,11 +107,7 @@ pub fn save_work_product_index(
|
|||||||
for (id, wp) in previous_work_products.iter() {
|
for (id, wp) in previous_work_products.iter() {
|
||||||
if !new_work_products.contains_key(id) {
|
if !new_work_products.contains_key(id) {
|
||||||
work_product::delete_workproduct_files(sess, wp);
|
work_product::delete_workproduct_files(sess, wp);
|
||||||
debug_assert!(
|
debug_assert!(!in_incr_comp_dir_sess(sess, &wp.saved_file).exists());
|
||||||
wp.saved_file.as_ref().map_or(true, |file_name| {
|
|
||||||
!in_incr_comp_dir_sess(sess, &file_name).exists()
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,8 +115,7 @@ pub fn save_work_product_index(
|
|||||||
debug_assert!({
|
debug_assert!({
|
||||||
new_work_products
|
new_work_products
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|(_, wp)| wp.saved_file.iter())
|
.map(|(_, wp)| in_incr_comp_dir_sess(sess, &wp.saved_file))
|
||||||
.map(|name| in_incr_comp_dir_sess(sess, name))
|
|
||||||
.all(|path| path.exists())
|
.all(|path| path.exists())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
|
|||||||
let file_name = format!("{}.o", cgu_name);
|
let file_name = format!("{}.o", cgu_name);
|
||||||
let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
|
let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
|
||||||
let saved_file = match link_or_copy(path, &path_in_incr_dir) {
|
let saved_file = match link_or_copy(path, &path_in_incr_dir) {
|
||||||
Ok(_) => Some(file_name),
|
Ok(_) => file_name,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
sess.warn(&format!(
|
sess.warn(&format!(
|
||||||
"error copying object file `{}` to incremental directory as `{}`: {}",
|
"error copying object file `{}` to incremental directory as `{}`: {}",
|
||||||
@ -41,8 +41,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
|
|||||||
|
|
||||||
/// Removes files for a given work product.
|
/// Removes files for a given work product.
|
||||||
pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) {
|
pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) {
|
||||||
if let Some(ref file_name) = work_product.saved_file {
|
let path = in_incr_comp_dir_sess(sess, &work_product.saved_file);
|
||||||
let path = in_incr_comp_dir_sess(sess, file_name);
|
|
||||||
match std_fs::remove_file(&path) {
|
match std_fs::remove_file(&path) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@ -54,4 +53,3 @@ pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -887,7 +887,7 @@ impl<K: DepKind> DepGraph<K> {
|
|||||||
pub struct WorkProduct {
|
pub struct WorkProduct {
|
||||||
pub cgu_name: String,
|
pub cgu_name: String,
|
||||||
/// Saved file associated with this CGU.
|
/// Saved file associated with this CGU.
|
||||||
pub saved_file: Option<String>,
|
pub saved_file: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Index type for `DepNodeData`'s edges.
|
// Index type for `DepNodeData`'s edges.
|
||||||
|
Loading…
Reference in New Issue
Block a user