Auto merge of #83846 - torhovland:issue-10971, r=davidtwco
Added the --temps-dir option Fixes #10971. The new `--temps-dir` option puts intermediate files in a user-specified directory. This provides a fix for the issue where parallel invocations of rustc would overwrite each other's intermediate files. No files are kept in the intermediate directory unless `-C save-temps=yes`. If additional files are specifically requested using `--emit asm,llvm-bc,llvm-ir,obj,metadata,link,dep-info,mir`, these will be put in the output directory rather than the intermediate directory. This is a backward-compatible change, i.e. if `--temps-dir` is not specified, the behavior is the same as before.
This commit is contained in:
commit
9dbbbb12c0
9 changed files with 72 additions and 5 deletions
|
@ -578,6 +578,7 @@ pub struct OutputFilenames {
|
|||
pub out_directory: PathBuf,
|
||||
filestem: String,
|
||||
pub single_output_file: Option<PathBuf>,
|
||||
pub temps_directory: Option<PathBuf>,
|
||||
pub outputs: OutputTypes,
|
||||
}
|
||||
|
||||
|
@ -592,12 +593,14 @@ impl OutputFilenames {
|
|||
out_directory: PathBuf,
|
||||
out_filestem: String,
|
||||
single_output_file: Option<PathBuf>,
|
||||
temps_directory: Option<PathBuf>,
|
||||
extra: String,
|
||||
outputs: OutputTypes,
|
||||
) -> Self {
|
||||
OutputFilenames {
|
||||
out_directory,
|
||||
single_output_file,
|
||||
temps_directory,
|
||||
outputs,
|
||||
filestem: format!("{}{}", out_filestem, extra),
|
||||
}
|
||||
|
@ -608,7 +611,14 @@ impl OutputFilenames {
|
|||
.get(&flavor)
|
||||
.and_then(|p| p.to_owned())
|
||||
.or_else(|| self.single_output_file.clone())
|
||||
.unwrap_or_else(|| self.temp_path(flavor, None))
|
||||
.unwrap_or_else(|| self.output_path(flavor))
|
||||
}
|
||||
|
||||
/// Gets the output path where a compilation artifact of the given type
|
||||
/// should be placed on disk.
|
||||
pub fn output_path(&self, flavor: OutputType) -> PathBuf {
|
||||
let extension = flavor.extension();
|
||||
self.with_directory_and_extension(&self.out_directory, &extension)
|
||||
}
|
||||
|
||||
/// Gets the path where a compilation artifact of the given type for the
|
||||
|
@ -643,11 +653,17 @@ impl OutputFilenames {
|
|||
extension.push_str(ext);
|
||||
}
|
||||
|
||||
self.with_extension(&extension)
|
||||
let temps_directory = self.temps_directory.as_ref().unwrap_or(&self.out_directory);
|
||||
|
||||
self.with_directory_and_extension(&temps_directory, &extension)
|
||||
}
|
||||
|
||||
pub fn with_extension(&self, extension: &str) -> PathBuf {
|
||||
let mut path = self.out_directory.join(&self.filestem);
|
||||
self.with_directory_and_extension(&self.out_directory, extension)
|
||||
}
|
||||
|
||||
fn with_directory_and_extension(&self, directory: &PathBuf, extension: &str) -> PathBuf {
|
||||
let mut path = directory.join(&self.filestem);
|
||||
path.set_extension(extension);
|
||||
path
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue