@@ -577,6 +577,25 @@ impl<'a> Builder<'a> {
577
577
} )
578
578
}
579
579
580
+ /// Similar to `compiler`, except handles the full-bootstrap option to
581
+ /// silently use the stage1 compiler instead of a stage2 compiler if one is
582
+ /// requested.
583
+ ///
584
+ /// Note that this does *not* have the side effect of creating
585
+ /// `compiler(stage, host)`, unlike `compiler` above which does have such
586
+ /// a side effect. The returned compiler here can only be used to compile
587
+ /// new artifacts, it can't be used to rely on the presence of a particular
588
+ /// sysroot.
589
+ ///
590
+ /// See `force_use_stage1` for documentation on what each argument is.
591
+ pub fn compiler_for ( & self , stage : u32 , host : Interned < String > , target : Interned < String > ) -> Compiler {
592
+ if self . build . force_use_stage1 ( Compiler { stage, host } , target) {
593
+ self . compiler ( 1 , self . config . build )
594
+ } else {
595
+ self . compiler ( stage, host)
596
+ }
597
+ }
598
+
580
599
pub fn sysroot ( & self , compiler : Compiler ) -> Interned < PathBuf > {
581
600
self . ensure ( compile:: Sysroot { compiler } )
582
601
}
@@ -750,11 +769,7 @@ impl<'a> Builder<'a> {
750
769
// This is for the original compiler, but if we're forced to use stage 1, then
751
770
// std/test/rustc stamps won't exist in stage 2, so we need to get those from stage 1, since
752
771
// we copy the libs forward.
753
- let cmp = if self . force_use_stage1 ( compiler, target) {
754
- self . compiler ( 1 , compiler. host )
755
- } else {
756
- compiler
757
- } ;
772
+ let cmp = self . compiler_for ( compiler. stage , compiler. host , target) ;
758
773
759
774
let libstd_stamp = match cmd {
760
775
"check" => check:: libstd_stamp ( self , cmp, target) ,
@@ -1371,7 +1386,7 @@ mod __test {
1371
1386
assert_eq ! (
1372
1387
first( builder. cache. all:: <dist:: Std >( ) ) ,
1373
1388
& [ dist:: Std {
1374
- compiler: Compiler { host: a, stage: 2 } ,
1389
+ compiler: Compiler { host: a, stage: 1 } ,
1375
1390
target: a,
1376
1391
} , ]
1377
1392
) ;
@@ -1408,7 +1423,7 @@ mod __test {
1408
1423
first( builder. cache. all:: <dist:: Std >( ) ) ,
1409
1424
& [
1410
1425
dist:: Std {
1411
- compiler: Compiler { host: a, stage: 2 } ,
1426
+ compiler: Compiler { host: a, stage: 1 } ,
1412
1427
target: a,
1413
1428
} ,
1414
1429
dist:: Std {
@@ -1455,18 +1470,51 @@ mod __test {
1455
1470
first( builder. cache. all:: <dist:: Std >( ) ) ,
1456
1471
& [
1457
1472
dist:: Std {
1458
- compiler: Compiler { host: a, stage: 2 } ,
1473
+ compiler: Compiler { host: a, stage: 1 } ,
1459
1474
target: a,
1460
1475
} ,
1461
1476
dist:: Std {
1462
- compiler: Compiler { host: a, stage: 2 } ,
1477
+ compiler: Compiler { host: a, stage: 1 } ,
1463
1478
target: b,
1464
1479
} ,
1465
1480
]
1466
1481
) ;
1467
1482
assert_eq ! ( first( builder. cache. all:: <dist:: Src >( ) ) , & [ dist:: Src ] ) ;
1468
1483
}
1469
1484
1485
+ #[ test]
1486
+ fn dist_only_cross_host ( ) {
1487
+ let a = INTERNER . intern_str ( "A" ) ;
1488
+ let b = INTERNER . intern_str ( "B" ) ;
1489
+ let mut build = Build :: new ( configure ( & [ "B" ] , & [ ] ) ) ;
1490
+ build. config . docs = false ;
1491
+ build. hosts = vec ! [ b] ;
1492
+ let mut builder = Builder :: new ( & build) ;
1493
+ builder. run_step_descriptions ( & Builder :: get_step_descriptions ( Kind :: Dist ) , & [ ] ) ;
1494
+
1495
+ assert_eq ! (
1496
+ first( builder. cache. all:: <dist:: Rustc >( ) ) ,
1497
+ & [
1498
+ dist:: Rustc {
1499
+ compiler: Compiler { host: b, stage: 2 }
1500
+ } ,
1501
+ ]
1502
+ ) ;
1503
+ assert_eq ! (
1504
+ first( builder. cache. all:: <compile:: Rustc >( ) ) ,
1505
+ & [
1506
+ compile:: Rustc {
1507
+ compiler: Compiler { host: a, stage: 0 } ,
1508
+ target: a,
1509
+ } ,
1510
+ compile:: Rustc {
1511
+ compiler: Compiler { host: a, stage: 1 } ,
1512
+ target: b,
1513
+ } ,
1514
+ ]
1515
+ ) ;
1516
+ }
1517
+
1470
1518
#[ test]
1471
1519
fn dist_with_targets_and_hosts ( ) {
1472
1520
let build = Build :: new ( configure ( & [ "B" ] , & [ "C" ] ) ) ;
@@ -1508,11 +1556,11 @@ mod __test {
1508
1556
first( builder. cache. all:: <dist:: Std >( ) ) ,
1509
1557
& [
1510
1558
dist:: Std {
1511
- compiler: Compiler { host: a, stage: 2 } ,
1559
+ compiler: Compiler { host: a, stage: 1 } ,
1512
1560
target: a,
1513
1561
} ,
1514
1562
dist:: Std {
1515
- compiler: Compiler { host: a, stage: 2 } ,
1563
+ compiler: Compiler { host: a, stage: 1 } ,
1516
1564
target: b,
1517
1565
} ,
1518
1566
dist:: Std {
@@ -1557,11 +1605,11 @@ mod __test {
1557
1605
first( builder. cache. all:: <dist:: Std >( ) ) ,
1558
1606
& [
1559
1607
dist:: Std {
1560
- compiler: Compiler { host: a, stage: 2 } ,
1608
+ compiler: Compiler { host: a, stage: 1 } ,
1561
1609
target: a,
1562
1610
} ,
1563
1611
dist:: Std {
1564
- compiler: Compiler { host: a, stage: 2 } ,
1612
+ compiler: Compiler { host: a, stage: 1 } ,
1565
1613
target: b,
1566
1614
} ,
1567
1615
dist:: Std {
@@ -1608,11 +1656,11 @@ mod __test {
1608
1656
first( builder. cache. all:: <dist:: Std >( ) ) ,
1609
1657
& [
1610
1658
dist:: Std {
1611
- compiler: Compiler { host: a, stage: 2 } ,
1659
+ compiler: Compiler { host: a, stage: 1 } ,
1612
1660
target: a,
1613
1661
} ,
1614
1662
dist:: Std {
1615
- compiler: Compiler { host: a, stage: 2 } ,
1663
+ compiler: Compiler { host: a, stage: 1 } ,
1616
1664
target: b,
1617
1665
} ,
1618
1666
]
@@ -1662,10 +1710,6 @@ mod __test {
1662
1710
compiler: Compiler { host: a, stage: 1 } ,
1663
1711
target: b,
1664
1712
} ,
1665
- compile:: Test {
1666
- compiler: Compiler { host: a, stage: 2 } ,
1667
- target: b,
1668
- } ,
1669
1713
]
1670
1714
) ;
1671
1715
assert_eq ! (
@@ -1718,10 +1762,6 @@ mod __test {
1718
1762
compiler: Compiler { host: b, stage: 2 } ,
1719
1763
target: a,
1720
1764
} ,
1721
- compile:: Rustc {
1722
- compiler: Compiler { host: a, stage: 0 } ,
1723
- target: b,
1724
- } ,
1725
1765
compile:: Rustc {
1726
1766
compiler: Compiler { host: a, stage: 1 } ,
1727
1767
target: b,
@@ -1756,10 +1796,6 @@ mod __test {
1756
1796
compiler: Compiler { host: b, stage: 2 } ,
1757
1797
target: a,
1758
1798
} ,
1759
- compile:: Test {
1760
- compiler: Compiler { host: a, stage: 0 } ,
1761
- target: b,
1762
- } ,
1763
1799
compile:: Test {
1764
1800
compiler: Compiler { host: a, stage: 1 } ,
1765
1801
target: b,
@@ -1806,9 +1842,6 @@ mod __test {
1806
1842
compile:: Assemble {
1807
1843
target_compiler: Compiler { host: a, stage: 1 } ,
1808
1844
} ,
1809
- compile:: Assemble {
1810
- target_compiler: Compiler { host: b, stage: 1 } ,
1811
- } ,
1812
1845
compile:: Assemble {
1813
1846
target_compiler: Compiler { host: a, stage: 2 } ,
1814
1847
} ,
@@ -1828,10 +1861,6 @@ mod __test {
1828
1861
compiler: Compiler { host: a, stage: 1 } ,
1829
1862
target: a,
1830
1863
} ,
1831
- compile:: Rustc {
1832
- compiler: Compiler { host: a, stage: 0 } ,
1833
- target: b,
1834
- } ,
1835
1864
compile:: Rustc {
1836
1865
compiler: Compiler { host: a, stage: 1 } ,
1837
1866
target: b,
@@ -1858,10 +1887,6 @@ mod __test {
1858
1887
compiler: Compiler { host: b, stage: 2 } ,
1859
1888
target: a,
1860
1889
} ,
1861
- compile:: Test {
1862
- compiler: Compiler { host: a, stage: 0 } ,
1863
- target: b,
1864
- } ,
1865
1890
compile:: Test {
1866
1891
compiler: Compiler { host: a, stage: 1 } ,
1867
1892
target: b,
0 commit comments