@@ -1025,15 +1025,26 @@ impl Builder<'_> {
10251025 if let Some ( ref map_to) =
10261026 self . build . debuginfo_map_to ( GitRepo :: Rustc , RemapScheme :: NonCompiler )
10271027 {
1028+ // Tell the compiler which prefix was used for remapping the standard library
10281029 cargo. env ( "CFG_VIRTUAL_RUST_SOURCE_BASE_DIR" , map_to) ;
10291030 }
10301031
10311032 if let Some ( ref map_to) =
10321033 self . build . debuginfo_map_to ( GitRepo :: Rustc , RemapScheme :: Compiler )
10331034 {
1034- // When building compiler sources, we want to apply the compiler remap scheme.
1035- cargo. env ( "RUSTC_DEBUGINFO_MAP" , format ! ( "compiler/={map_to}/compiler" ) ) ;
1035+ // Tell the compiler which prefix was used for remapping the compiler it-self
10361036 cargo. env ( "CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR" , map_to) ;
1037+
1038+ // When building compiler sources, we want to apply the compiler remap scheme.
1039+ let map = [
1040+ // Cargo use relative paths for workspace members, so let's remap those.
1041+ format ! ( "compiler/={map_to}/compiler" ) ,
1042+ // rustc creates absolute paths (in part bc of the `rust-src` unremap
1043+ // and for working directory) so let's remap the build directory as well.
1044+ format ! ( "{}={map_to}" , self . build. src. display( ) ) ,
1045+ ]
1046+ . join ( "\t " ) ;
1047+ cargo. env ( "RUSTC_DEBUGINFO_MAP" , map) ;
10371048 }
10381049 }
10391050 Mode :: Std
@@ -1044,7 +1055,16 @@ impl Builder<'_> {
10441055 if let Some ( ref map_to) =
10451056 self . build . debuginfo_map_to ( GitRepo :: Rustc , RemapScheme :: NonCompiler )
10461057 {
1047- cargo. env ( "RUSTC_DEBUGINFO_MAP" , format ! ( "library/={map_to}/library" ) ) ;
1058+ // When building the standard library sources, we want to apply the std remap scheme.
1059+ let map = [
1060+ // Cargo use relative paths for workspace members, so let's remap those.
1061+ format ! ( "library/={map_to}/library" ) ,
1062+ // rustc creates absolute paths (in part bc of the `rust-src` unremap
1063+ // and for working directory) so let's remap the build directory as well.
1064+ format ! ( "{}={map_to}" , self . build. src. display( ) ) ,
1065+ ]
1066+ . join ( "\t " ) ;
1067+ cargo. env ( "RUSTC_DEBUGINFO_MAP" , map) ;
10481068 }
10491069 }
10501070 }
0 commit comments