Avoid no-op unlink+link dances in incr comp
This commit is contained in:
parent
9af8985e05
commit
cae7c76d50
6 changed files with 50 additions and 21 deletions
|
@ -540,9 +540,12 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
|
|||
if let Some(path) = &module.bytecode {
|
||||
files.push((OutputType::Bitcode.extension(), path.as_path()));
|
||||
}
|
||||
if let Some((id, product)) =
|
||||
copy_cgu_workproduct_to_incr_comp_cache_dir(sess, &module.name, files.as_slice())
|
||||
{
|
||||
if let Some((id, product)) = copy_cgu_workproduct_to_incr_comp_cache_dir(
|
||||
sess,
|
||||
&module.name,
|
||||
files.as_slice(),
|
||||
&module.links_from_incr_cache,
|
||||
) {
|
||||
work_products.insert(id, product);
|
||||
}
|
||||
}
|
||||
|
@ -934,7 +937,9 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
|
|||
) -> WorkItemResult<B> {
|
||||
let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();
|
||||
|
||||
let load_from_incr_comp_dir = |output_path: PathBuf, saved_path: &str| {
|
||||
let mut links_from_incr_cache = Vec::new();
|
||||
|
||||
let mut load_from_incr_comp_dir = |output_path: PathBuf, saved_path: &str| {
|
||||
let source_file = in_incr_comp_dir(incr_comp_session_dir, saved_path);
|
||||
debug!(
|
||||
"copying preexisting module `{}` from {:?} to {}",
|
||||
|
@ -943,7 +948,10 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
|
|||
output_path.display()
|
||||
);
|
||||
match link_or_copy(&source_file, &output_path) {
|
||||
Ok(_) => Some(output_path),
|
||||
Ok(_) => {
|
||||
links_from_incr_cache.push(source_file);
|
||||
Some(output_path)
|
||||
}
|
||||
Err(error) => {
|
||||
cgcx.create_dcx().handle().emit_err(errors::CopyPathBuf {
|
||||
source_file,
|
||||
|
@ -966,7 +974,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
|
|||
load_from_incr_comp_dir(dwarf_obj_out, saved_dwarf_object_file)
|
||||
});
|
||||
|
||||
let load_from_incr_cache = |perform, output_type: OutputType| {
|
||||
let mut load_from_incr_cache = |perform, output_type: OutputType| {
|
||||
if perform {
|
||||
let saved_file = module.source.saved_files.get(output_type.extension())?;
|
||||
let output_path = cgcx.output_filenames.temp_path(output_type, Some(&module.name));
|
||||
|
@ -986,6 +994,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
|
|||
}
|
||||
|
||||
WorkItemResult::Finished(CompiledModule {
|
||||
links_from_incr_cache,
|
||||
name: module.name,
|
||||
kind: ModuleKind::Regular,
|
||||
object,
|
||||
|
|
|
@ -656,6 +656,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
|||
bytecode: None,
|
||||
assembly: None,
|
||||
llvm_ir: None,
|
||||
links_from_incr_cache: Vec::new(),
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
|
@ -102,6 +102,7 @@ impl<M> ModuleCodegen<M> {
|
|||
bytecode,
|
||||
assembly,
|
||||
llvm_ir,
|
||||
links_from_incr_cache: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +116,7 @@ pub struct CompiledModule {
|
|||
pub bytecode: Option<PathBuf>,
|
||||
pub assembly: Option<PathBuf>, // --emit=asm
|
||||
pub llvm_ir: Option<PathBuf>, // --emit=llvm-ir, llvm-bc is in bytecode
|
||||
pub links_from_incr_cache: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
impl CompiledModule {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue