diff options
| author | Urgau <urgau@numericable.fr> | 2024-03-21 21:13:06 +0100 |
|---|---|---|
| committer | Urgau <urgau@numericable.fr> | 2024-03-28 18:47:26 +0100 |
| commit | 4f4fa42b0ee1cf6c988d3f7ed6bcb4a51e788282 (patch) | |
| tree | 9057c7917e19c80dfdf90cfc2d3d9f564a9cc344 /compiler/rustc_codegen_llvm/src | |
| parent | ee2898d3f1cbece34153581823fafa7f572bbff0 (diff) | |
| download | rust-4f4fa42b0ee1cf6c988d3f7ed6bcb4a51e788282.tar.gz rust-4f4fa42b0ee1cf6c988d3f7ed6bcb4a51e788282.zip | |
Introduce `FileNameMapping::to_real_filename` and use it everywhere
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/write.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs | 31 |
2 files changed, 16 insertions, 20 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index 98480dc90c6..d27df052d43 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -264,10 +264,11 @@ pub fn target_machine_factory( Arc::new(move |config: TargetMachineFactoryConfig| { let path_to_cstring_helper = |path: Option<PathBuf>| -> CString { let path = path.unwrap_or_default(); + let path = path_mapping.to_real_filename(path); let path = if should_prefer_remapped_paths { - path_mapping.map_prefix(path).0 + path.remapped_path_if_available() } else { - path.into() + path.local_path_if_available() }; CString::new(path.to_str().unwrap()).unwrap() }; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index cd97929024a..4dd51adc67b 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -878,26 +878,21 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>( .for_scope(tcx.sess, RemapPathScopeComponents::DEBUGINFO) .to_string_lossy(); let output_filenames = tcx.output_filenames(()); - let split_name = if tcx.sess.target_can_use_split_dwarf() { - output_filenames - .split_dwarf_path( - tcx.sess.split_debuginfo(), - tcx.sess.opts.unstable_opts.split_dwarf_kind, - Some(codegen_unit_name), - ) - // We get a path relative to the working directory from split_dwarf_path - .map(|f| { - if tcx.sess.should_prefer_remapped(RemapPathScopeComponents::DEBUGINFO) { - tcx.sess.source_map().path_mapping().map_prefix(f).0 - } else { - f.into() - } - }) + let split_name = if tcx.sess.target_can_use_split_dwarf() + && let Some(f) = output_filenames.split_dwarf_path( + tcx.sess.split_debuginfo(), + tcx.sess.opts.unstable_opts.split_dwarf_kind, + Some(codegen_unit_name), + ) { + // We get a path relative to the working directory from split_dwarf_path + Some(tcx.sess.source_map().path_mapping().to_real_filename(f)) } else { None - } - .unwrap_or_default(); - let split_name = split_name.to_str().unwrap(); + }; + let split_name = split_name + .as_ref() + .map(|f| f.for_scope(tcx.sess, RemapPathScopeComponents::DEBUGINFO).to_string_lossy()) + .unwrap_or_default(); let kind = DebugEmissionKind::from_generic(tcx.sess.opts.debuginfo); let dwarf_version = |
