@@ -412,9 +412,13 @@ impl Blueprint {
412412 }
413413
414414 /// Add $CRATE to `patch` section, as needed to build libstd.
415- fn add_patch ( patch : & mut Table , mut path : PathBuf , crate_ : & str ) -> Result < ( ) > {
416- path. push ( crate_) ;
417- if path. exists ( ) {
415+ fn add_patch ( patch : & mut Table , src_path : & Path , crate_ : & str ) -> Result < ( ) > {
416+ // Old sysroots have this in `src/tools/$CRATE`, new sysroots in `library/$CRATE`.
417+ let paths = [
418+ src_path. join ( crate_) ,
419+ src_path. join ( "tools" ) . join ( crate_) ,
420+ ] ;
421+ if let Some ( path) = paths. iter ( ) . find ( |p| p. exists ( ) ) {
418422 // add crate to patch section (if not specified)
419423 fn table_entry < ' a > ( table : & ' a mut Table , key : & str ) -> Result < & ' a mut Table > {
420424 table
@@ -479,9 +483,9 @@ impl Blueprint {
479483 }
480484 }
481485
482- Blueprint :: add_patch ( & mut patch, src. path ( ) . join ( "tools" ) , "rustc-std-workspace-core" ) ?;
483- Blueprint :: add_patch ( & mut patch, src. path ( ) . join ( "tools" ) , "rustc-std-workspace-alloc" ) ?;
484- Blueprint :: add_patch ( & mut patch, src. path ( ) . join ( "tools" ) , "rustc-std-workspace-std" ) ?;
486+ Blueprint :: add_patch ( & mut patch, src. path ( ) , "rustc-std-workspace-core" ) ?;
487+ Blueprint :: add_patch ( & mut patch, src. path ( ) , "rustc-std-workspace-alloc" ) ?;
488+ Blueprint :: add_patch ( & mut patch, src. path ( ) , "rustc-std-workspace-std" ) ?;
485489
486490 // Compose dependency sections
487491 let deps = match (
@@ -559,8 +563,13 @@ impl Blueprint {
559563
560564 if !map. contains_key ( "path" ) && !map. contains_key ( "git" ) {
561565 // No path and no git given. This might be in the sysroot, but if we don't find it there we assume it comes from crates.io.
562- let path = src. path ( ) . join ( format ! ( "lib{}" , k) ) ;
563- if path. exists ( ) {
566+ // Current sysroots call it just "std" (etc), but older sysroots use "libstd" (etc),
567+ // so we check both.
568+ let paths = [
569+ src. path ( ) . join ( & k) ,
570+ src. path ( ) . join ( format ! ( "lib{}" , k) ) ,
571+ ] ;
572+ if let Some ( path) = paths. iter ( ) . find ( |p| p. exists ( ) ) {
564573 map. insert ( "path" . to_owned ( ) , Value :: String ( path. display ( ) . to_string ( ) ) ) ;
565574 }
566575 }
0 commit comments