@@ -412,9 +412,13 @@ impl Blueprint {
412
412
}
413
413
414
414
/// 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 ( ) ) {
418
422
// add crate to patch section (if not specified)
419
423
fn table_entry < ' a > ( table : & ' a mut Table , key : & str ) -> Result < & ' a mut Table > {
420
424
table
@@ -479,9 +483,9 @@ impl Blueprint {
479
483
}
480
484
}
481
485
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" ) ?;
485
489
486
490
// Compose dependency sections
487
491
let deps = match (
@@ -559,8 +563,13 @@ impl Blueprint {
559
563
560
564
if !map. contains_key ( "path" ) && !map. contains_key ( "git" ) {
561
565
// 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 ( ) ) {
564
573
map. insert ( "path" . to_owned ( ) , Value :: String ( path. display ( ) . to_string ( ) ) ) ;
565
574
}
566
575
}
0 commit comments