@@ -878,26 +878,21 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
878878 . for_scope ( tcx. sess , RemapPathScopeComponents :: DEBUGINFO )
879879 . to_string_lossy ( ) ;
880880 let output_filenames = tcx. output_filenames ( ( ) ) ;
881- let split_name = if tcx. sess . target_can_use_split_dwarf ( ) {
882- output_filenames
883- . split_dwarf_path (
884- tcx. sess . split_debuginfo ( ) ,
885- tcx. sess . opts . unstable_opts . split_dwarf_kind ,
886- Some ( codegen_unit_name) ,
887- )
888- // We get a path relative to the working directory from split_dwarf_path
889- . map ( |f| {
890- if tcx. sess . should_prefer_remapped ( RemapPathScopeComponents :: DEBUGINFO ) {
891- tcx. sess . source_map ( ) . path_mapping ( ) . map_prefix ( f) . 0
892- } else {
893- f. into ( )
894- }
895- } )
881+ let split_name = if tcx. sess . target_can_use_split_dwarf ( )
882+ && let Some ( f) = output_filenames. split_dwarf_path (
883+ tcx. sess . split_debuginfo ( ) ,
884+ tcx. sess . opts . unstable_opts . split_dwarf_kind ,
885+ Some ( codegen_unit_name) ,
886+ ) {
887+ // We get a path relative to the working directory from split_dwarf_path
888+ Some ( tcx. sess . source_map ( ) . path_mapping ( ) . to_real_filename ( f) )
896889 } else {
897890 None
898- }
899- . unwrap_or_default ( ) ;
900- let split_name = split_name. to_str ( ) . unwrap ( ) ;
891+ } ;
892+ let split_name = split_name
893+ . as_ref ( )
894+ . map ( |f| f. for_scope ( tcx. sess , RemapPathScopeComponents :: DEBUGINFO ) . to_string_lossy ( ) )
895+ . unwrap_or_default ( ) ;
901896 let kind = DebugEmissionKind :: from_generic ( tcx. sess . opts . debuginfo ) ;
902897
903898 let dwarf_version =
0 commit comments