Make .rmeta
file in dep-info
have correct name (lib
prefix)
Since `filename_for_metadata()` and `OutputFilenames::path(OutputType::Metadata)` had different logic for the name of the metadata file, the `.d` file contained a file name different from the actual name used. Share the logic to fix the out-of-sync name. Closes 68839.
This commit is contained in:
parent
e286f25ec0
commit
04d81ba153
7 changed files with 49 additions and 28 deletions
|
@ -880,6 +880,9 @@ impl OutFileName {
|
|||
#[derive(Clone, Hash, Debug, HashStable_Generic)]
|
||||
pub struct OutputFilenames {
|
||||
pub out_directory: PathBuf,
|
||||
/// Crate name. Never contains '-'.
|
||||
crate_stem: String,
|
||||
/// Typically based on `.rs` input file name. Any '-' is preserved.
|
||||
filestem: String,
|
||||
pub single_output_file: Option<OutFileName>,
|
||||
pub temps_directory: Option<PathBuf>,
|
||||
|
@ -893,6 +896,7 @@ pub const DWARF_OBJECT_EXT: &str = "dwo";
|
|||
impl OutputFilenames {
|
||||
pub fn new(
|
||||
out_directory: PathBuf,
|
||||
out_crate_name: String,
|
||||
out_filestem: String,
|
||||
single_output_file: Option<OutFileName>,
|
||||
temps_directory: Option<PathBuf>,
|
||||
|
@ -904,6 +908,7 @@ impl OutputFilenames {
|
|||
single_output_file,
|
||||
temps_directory,
|
||||
outputs,
|
||||
crate_stem: format!("{out_crate_name}{extra}"),
|
||||
filestem: format!("{out_filestem}{extra}"),
|
||||
}
|
||||
}
|
||||
|
@ -920,7 +925,12 @@ impl OutputFilenames {
|
|||
/// 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)
|
||||
match flavor {
|
||||
OutputType::Metadata => {
|
||||
self.out_directory.join(format!("lib{}.{}", self.crate_stem, extension))
|
||||
}
|
||||
_ => self.with_directory_and_extension(&self.out_directory, extension),
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets the path where a compilation artifact of the given type for the
|
||||
|
|
|
@ -119,26 +119,11 @@ pub fn validate_crate_name(sess: &Session, s: Symbol, sp: Option<Span>) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn filename_for_metadata(
|
||||
sess: &Session,
|
||||
crate_name: Symbol,
|
||||
outputs: &OutputFilenames,
|
||||
) -> OutFileName {
|
||||
// If the command-line specified the path, use that directly.
|
||||
if let Some(Some(out_filename)) = sess.opts.output_types.get(&OutputType::Metadata) {
|
||||
return out_filename.clone();
|
||||
}
|
||||
|
||||
let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename);
|
||||
|
||||
let out_filename = outputs.single_output_file.clone().unwrap_or_else(|| {
|
||||
OutFileName::Real(outputs.out_directory.join(&format!("lib{libname}.rmeta")))
|
||||
});
|
||||
|
||||
pub fn filename_for_metadata(sess: &Session, outputs: &OutputFilenames) -> OutFileName {
|
||||
let out_filename = outputs.path(OutputType::Metadata);
|
||||
if let OutFileName::Real(ref path) = out_filename {
|
||||
check_file_is_writeable(path, sess);
|
||||
}
|
||||
|
||||
out_filename
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue