diff options
| author | Andy Wang <cbeuw.andy@gmail.com> | 2021-04-19 20:07:27 +0100 |
|---|---|---|
| committer | Andy Wang <cbeuw.andy@gmail.com> | 2021-05-05 15:30:55 +0100 |
| commit | ec34cd94dd88d0d564902b5c65d3a2d2e71636c8 (patch) | |
| tree | ba088456c32d2dc2fb3511a8fb3ae989a43f3bfc /compiler | |
| parent | e5445f3722ff0e97681139480931166f791c28a7 (diff) | |
| download | rust-ec34cd94dd88d0d564902b5c65d3a2d2e71636c8.tar.gz rust-ec34cd94dd88d0d564902b5c65d3a2d2e71636c8.zip | |
Use local name if available in write_out_deps
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_interface/src/passes.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 2f91a72e208..1d3109c8a29 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -36,7 +36,7 @@ use rustc_session::output::{filename_for_input, filename_for_metadata}; use rustc_session::search_paths::PathKind; use rustc_session::Session; use rustc_span::symbol::{Ident, Symbol}; -use rustc_span::{FileName, RealFileName}; +use rustc_span::FileName; use rustc_trait_selection::traits; use rustc_typeck as typeck; use tracing::{info, warn}; @@ -532,10 +532,10 @@ fn output_conflicts_with_dir(output_paths: &[PathBuf]) -> Option<PathBuf> { check_output(output_paths, check) } -fn escape_dep_filename(filename: &FileName) -> String { +fn escape_dep_filename(filename: &String) -> String { // Apparently clang and gcc *only* escape spaces: // http://llvm.org/klaus/clang/commit/9d50634cfc268ecc9a7250226dd5ca0e945240d4 - filename.to_string().replace(" ", "\\ ") + filename.replace(" ", "\\ ") } // Makefile comments only need escaping newlines and `\`. @@ -575,7 +575,14 @@ fn write_out_deps( .iter() .filter(|fmap| fmap.is_real_file()) .filter(|fmap| !fmap.is_imported()) - .map(|fmap| escape_dep_filename(&fmap.name)) + .map(|fmap| { + escape_dep_filename(&match &fmap.name { + FileName::Real(real) => { + real.local_path().unwrap_or(real.stable_name()).display().to_string() + } + _ => fmap.name.to_string(), + }) + }) .collect(); if let Some(ref backend) = sess.opts.debugging_opts.codegen_backend { @@ -587,16 +594,13 @@ fn write_out_deps( for cnum in resolver.cstore().crates_untracked() { let source = resolver.cstore().crate_source_untracked(cnum); if let Some((path, _)) = source.dylib { - let file_name = FileName::Real(RealFileName::LocalPath(path)); - files.push(escape_dep_filename(&file_name)); + files.push(escape_dep_filename(&path.display().to_string())); } if let Some((path, _)) = source.rlib { - let file_name = FileName::Real(RealFileName::LocalPath(path)); - files.push(escape_dep_filename(&file_name)); + files.push(escape_dep_filename(&path.display().to_string())); } if let Some((path, _)) = source.rmeta { - let file_name = FileName::Real(RealFileName::LocalPath(path)); - files.push(escape_dep_filename(&file_name)); + files.push(escape_dep_filename(&path.display().to_string())); } } }); |
