Prepend temp files with a string per invocation of rustc
This commit is contained in:
parent
effef88ac7
commit
9c372d8940
17 changed files with 260 additions and 50 deletions
|
@ -112,7 +112,12 @@ pub fn link_binary(
|
|||
codegen_results.crate_info.local_crate_name,
|
||||
);
|
||||
let crate_name = format!("{}", codegen_results.crate_info.local_crate_name);
|
||||
let out_filename = output.file_for_writing(outputs, OutputType::Exe, &crate_name);
|
||||
let out_filename = output.file_for_writing(
|
||||
outputs,
|
||||
OutputType::Exe,
|
||||
&crate_name,
|
||||
sess.invocation_temp.as_deref(),
|
||||
);
|
||||
match crate_type {
|
||||
CrateType::Rlib => {
|
||||
let _timer = sess.timer("link_rlib");
|
||||
|
|
|
@ -307,13 +307,17 @@ impl TargetMachineFactoryConfig {
|
|||
cgcx.split_debuginfo,
|
||||
cgcx.split_dwarf_kind,
|
||||
module_name,
|
||||
cgcx.invocation_temp.as_deref(),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let output_obj_file =
|
||||
Some(cgcx.output_filenames.temp_path_for_cgu(OutputType::Object, module_name));
|
||||
let output_obj_file = Some(cgcx.output_filenames.temp_path_for_cgu(
|
||||
OutputType::Object,
|
||||
module_name,
|
||||
cgcx.invocation_temp.as_deref(),
|
||||
));
|
||||
TargetMachineFactoryConfig { split_dwarf_file, output_obj_file }
|
||||
}
|
||||
}
|
||||
|
@ -344,6 +348,7 @@ pub struct CodegenContext<B: WriteBackendMethods> {
|
|||
pub crate_types: Vec<CrateType>,
|
||||
pub each_linked_rlib_for_lto: Vec<(CrateNum, PathBuf)>,
|
||||
pub output_filenames: Arc<OutputFilenames>,
|
||||
pub invocation_temp: Option<String>,
|
||||
pub regular_module_config: Arc<ModuleConfig>,
|
||||
pub metadata_module_config: Arc<ModuleConfig>,
|
||||
pub allocator_module_config: Arc<ModuleConfig>,
|
||||
|
@ -582,7 +587,11 @@ fn produce_final_output_artifacts(
|
|||
if let [module] = &compiled_modules.modules[..] {
|
||||
// 1) Only one codegen unit. In this case it's no difficulty
|
||||
// to copy `foo.0.x` to `foo.x`.
|
||||
let path = crate_output.temp_path_for_cgu(output_type, &module.name);
|
||||
let path = crate_output.temp_path_for_cgu(
|
||||
output_type,
|
||||
&module.name,
|
||||
sess.invocation_temp.as_deref(),
|
||||
);
|
||||
let output = crate_output.path(output_type);
|
||||
if !output_type.is_text_output() && output.is_tty() {
|
||||
sess.dcx()
|
||||
|
@ -959,7 +968,12 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
|
|||
module.source.saved_files.get("dwo").as_ref().and_then(|saved_dwarf_object_file| {
|
||||
let dwarf_obj_out = cgcx
|
||||
.output_filenames
|
||||
.split_dwarf_path(cgcx.split_debuginfo, cgcx.split_dwarf_kind, &module.name)
|
||||
.split_dwarf_path(
|
||||
cgcx.split_debuginfo,
|
||||
cgcx.split_dwarf_kind,
|
||||
&module.name,
|
||||
cgcx.invocation_temp.as_deref(),
|
||||
)
|
||||
.expect(
|
||||
"saved dwarf object in work product but `split_dwarf_path` returned `None`",
|
||||
);
|
||||
|
@ -969,7 +983,11 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
|
|||
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_for_cgu(output_type, &module.name);
|
||||
let output_path = cgcx.output_filenames.temp_path_for_cgu(
|
||||
output_type,
|
||||
&module.name,
|
||||
cgcx.invocation_temp.as_deref(),
|
||||
);
|
||||
load_from_incr_comp_dir(output_path, &saved_file)
|
||||
} else {
|
||||
None
|
||||
|
@ -1214,6 +1232,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
split_dwarf_kind: tcx.sess.opts.unstable_opts.split_dwarf_kind,
|
||||
parallel: backend.supports_parallel() && !sess.opts.unstable_opts.no_parallel_backend,
|
||||
pointer_size: tcx.data_layout.pointer_size,
|
||||
invocation_temp: sess.invocation_temp.clone(),
|
||||
};
|
||||
|
||||
// This is the "main loop" of parallel work happening for parallel codegen.
|
||||
|
|
|
@ -640,9 +640,11 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
|||
let metadata_cgu_name =
|
||||
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("metadata")).to_string();
|
||||
tcx.sess.time("write_compressed_metadata", || {
|
||||
let file_name = tcx
|
||||
.output_filenames(())
|
||||
.temp_path_for_cgu(OutputType::Metadata, &metadata_cgu_name);
|
||||
let file_name = tcx.output_filenames(()).temp_path_for_cgu(
|
||||
OutputType::Metadata,
|
||||
&metadata_cgu_name,
|
||||
tcx.sess.invocation_temp.as_deref(),
|
||||
);
|
||||
let data = create_compressed_metadata_file(
|
||||
tcx.sess,
|
||||
&metadata,
|
||||
|
|
|
@ -105,14 +105,19 @@ impl<M> ModuleCodegen<M> {
|
|||
emit_asm: bool,
|
||||
emit_ir: bool,
|
||||
outputs: &OutputFilenames,
|
||||
invocation_temp: Option<&str>,
|
||||
) -> CompiledModule {
|
||||
let object = emit_obj.then(|| outputs.temp_path_for_cgu(OutputType::Object, &self.name));
|
||||
let dwarf_object = emit_dwarf_obj.then(|| outputs.temp_path_dwo_for_cgu(&self.name));
|
||||
let bytecode = emit_bc.then(|| outputs.temp_path_for_cgu(OutputType::Bitcode, &self.name));
|
||||
let assembly =
|
||||
emit_asm.then(|| outputs.temp_path_for_cgu(OutputType::Assembly, &self.name));
|
||||
let llvm_ir =
|
||||
emit_ir.then(|| outputs.temp_path_for_cgu(OutputType::LlvmAssembly, &self.name));
|
||||
let object = emit_obj
|
||||
.then(|| outputs.temp_path_for_cgu(OutputType::Object, &self.name, invocation_temp));
|
||||
let dwarf_object =
|
||||
emit_dwarf_obj.then(|| outputs.temp_path_dwo_for_cgu(&self.name, invocation_temp));
|
||||
let bytecode = emit_bc
|
||||
.then(|| outputs.temp_path_for_cgu(OutputType::Bitcode, &self.name, invocation_temp));
|
||||
let assembly = emit_asm
|
||||
.then(|| outputs.temp_path_for_cgu(OutputType::Assembly, &self.name, invocation_temp));
|
||||
let llvm_ir = emit_ir.then(|| {
|
||||
outputs.temp_path_for_cgu(OutputType::LlvmAssembly, &self.name, invocation_temp)
|
||||
});
|
||||
|
||||
CompiledModule {
|
||||
name: self.name.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue