@@ -554,13 +554,16 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
554
554
) -> & ' ll DIFile {
555
555
debug ! ( ?source_file. name) ;
556
556
557
- use rustc_session:: RemapFileNameExt ;
557
+ let filename_display_preference =
558
+ cx. sess ( ) . filename_display_preference ( RemapPathScopeComponents :: DEBUGINFO ) ;
559
+
560
+ use rustc_session:: config:: RemapPathScopeComponents ;
558
561
let ( directory, file_name) = match & source_file. name {
559
562
FileName :: Real ( filename) => {
560
563
let working_directory = & cx. sess ( ) . opts . working_dir ;
561
564
debug ! ( ?working_directory) ;
562
565
563
- if cx . sess ( ) . should_prefer_remapped_for_codegen ( ) {
566
+ if filename_display_preference == FileNameDisplayPreference :: Remapped {
564
567
let filename = cx
565
568
. sess ( )
566
569
. source_map ( )
@@ -623,7 +626,7 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
623
626
}
624
627
other => {
625
628
debug ! ( ?other) ;
626
- ( "" . into ( ) , other. for_codegen ( cx . sess ( ) ) . to_string_lossy ( ) . into_owned ( ) )
629
+ ( "" . into ( ) , other. display ( filename_display_preference ) . to_string ( ) )
627
630
}
628
631
} ;
629
632
@@ -832,9 +835,11 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
832
835
codegen_unit_name : & str ,
833
836
debug_context : & CodegenUnitDebugContext < ' ll , ' tcx > ,
834
837
) -> & ' ll DIDescriptor {
838
+ use rustc_session:: { config:: RemapPathScopeComponents , RemapFileNameExt } ;
835
839
let mut name_in_debuginfo = tcx
836
840
. sess
837
841
. local_crate_source_file ( )
842
+ . map ( |src| src. for_scope ( & tcx. sess , RemapPathScopeComponents :: DEBUGINFO ) . to_path_buf ( ) )
838
843
. unwrap_or_else ( || PathBuf :: from ( tcx. crate_name ( LOCAL_CRATE ) . as_str ( ) ) ) ;
839
844
840
845
// To avoid breaking split DWARF, we need to ensure that each codegen unit
@@ -862,30 +867,29 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
862
867
// FIXME(#41252) Remove "clang LLVM" if we can get GDB and LLVM to play nice.
863
868
let producer = format ! ( "clang LLVM ({rustc_producer})" ) ;
864
869
865
- use rustc_session:: RemapFileNameExt ;
866
870
let name_in_debuginfo = name_in_debuginfo. to_string_lossy ( ) ;
867
- let work_dir = tcx. sess . opts . working_dir . for_codegen ( tcx. sess ) . to_string_lossy ( ) ;
871
+ let work_dir = tcx
872
+ . sess
873
+ . opts
874
+ . working_dir
875
+ . for_scope ( tcx. sess , RemapPathScopeComponents :: DEBUGINFO )
876
+ . to_string_lossy ( ) ;
868
877
let output_filenames = tcx. output_filenames ( ( ) ) ;
869
- let split_name = if tcx. sess . target_can_use_split_dwarf ( ) {
870
- output_filenames
871
- . split_dwarf_path (
872
- tcx. sess . split_debuginfo ( ) ,
873
- tcx. sess . opts . unstable_opts . split_dwarf_kind ,
874
- Some ( codegen_unit_name) ,
875
- )
876
- // We get a path relative to the working directory from split_dwarf_path
877
- . map ( |f| {
878
- if tcx. sess . should_prefer_remapped_for_split_debuginfo_paths ( ) {
879
- tcx. sess . source_map ( ) . path_mapping ( ) . map_prefix ( f) . 0
880
- } else {
881
- f. into ( )
882
- }
883
- } )
878
+ let split_name = if tcx. sess . target_can_use_split_dwarf ( )
879
+ && let Some ( f) = output_filenames. split_dwarf_path (
880
+ tcx. sess . split_debuginfo ( ) ,
881
+ tcx. sess . opts . unstable_opts . split_dwarf_kind ,
882
+ Some ( codegen_unit_name) ,
883
+ ) {
884
+ // We get a path relative to the working directory from split_dwarf_path
885
+ Some ( tcx. sess . source_map ( ) . path_mapping ( ) . to_real_filename ( f) )
884
886
} else {
885
887
None
886
- }
887
- . unwrap_or_default ( ) ;
888
- let split_name = split_name. to_str ( ) . unwrap ( ) ;
888
+ } ;
889
+ let split_name = split_name
890
+ . as_ref ( )
891
+ . map ( |f| f. for_scope ( tcx. sess , RemapPathScopeComponents :: DEBUGINFO ) . to_string_lossy ( ) )
892
+ . unwrap_or_default ( ) ;
889
893
let kind = DebugEmissionKind :: from_generic ( tcx. sess . opts . debuginfo ) ;
890
894
891
895
let dwarf_version =
0 commit comments