@@ -581,6 +581,30 @@ impl<'a> Builder<'a> {
581
581
} )
582
582
}
583
583
584
+ /// Similar to `compiler`, except handles the full-bootstrap option to
585
+ /// silently use the stage1 compiler instead of a stage2 compiler if one is
586
+ /// requested.
587
+ ///
588
+ /// Note that this does *not* have the side effect of creating
589
+ /// `compiler(stage, host)`, unlike `compiler` above which does have such
590
+ /// a side effect. The returned compiler here can only be used to compile
591
+ /// new artifacts, it can't be used to rely on the presence of a particular
592
+ /// sysroot.
593
+ ///
594
+ /// See `force_use_stage1` for documentation on what each argument is.
595
+ pub fn compiler_for (
596
+ & self ,
597
+ stage : u32 ,
598
+ host : Interned < String > ,
599
+ target : Interned < String > ,
600
+ ) -> Compiler {
601
+ if self . build . force_use_stage1 ( Compiler { stage, host } , target) {
602
+ self . compiler ( 1 , self . config . build )
603
+ } else {
604
+ self . compiler ( stage, host)
605
+ }
606
+ }
607
+
584
608
pub fn sysroot ( & self , compiler : Compiler ) -> Interned < PathBuf > {
585
609
self . ensure ( compile:: Sysroot { compiler } )
586
610
}
@@ -754,11 +778,7 @@ impl<'a> Builder<'a> {
754
778
// This is for the original compiler, but if we're forced to use stage 1, then
755
779
// std/test/rustc stamps won't exist in stage 2, so we need to get those from stage 1, since
756
780
// we copy the libs forward.
757
- let cmp = if self . force_use_stage1 ( compiler, target) {
758
- self . compiler ( 1 , compiler. host )
759
- } else {
760
- compiler
761
- } ;
781
+ let cmp = self . compiler_for ( compiler. stage , compiler. host , target) ;
762
782
763
783
let libstd_stamp = match cmd {
764
784
"check" | "clippy" | "fix" => check:: libstd_stamp ( self , cmp, target) ,
@@ -1358,7 +1378,7 @@ mod __test {
1358
1378
1359
1379
assert_eq ! (
1360
1380
first( builder. cache. all:: <dist:: Docs >( ) ) ,
1361
- & [ dist:: Docs { stage : 2 , host: a } , ]
1381
+ & [ dist:: Docs { host: a } , ]
1362
1382
) ;
1363
1383
assert_eq ! (
1364
1384
first( builder. cache. all:: <dist:: Mingw >( ) ) ,
@@ -1373,7 +1393,7 @@ mod __test {
1373
1393
assert_eq ! (
1374
1394
first( builder. cache. all:: <dist:: Std >( ) ) ,
1375
1395
& [ dist:: Std {
1376
- compiler: Compiler { host: a, stage: 2 } ,
1396
+ compiler: Compiler { host: a, stage: 1 } ,
1377
1397
target: a,
1378
1398
} , ]
1379
1399
) ;
@@ -1392,8 +1412,8 @@ mod __test {
1392
1412
assert_eq ! (
1393
1413
first( builder. cache. all:: <dist:: Docs >( ) ) ,
1394
1414
& [
1395
- dist:: Docs { stage : 2 , host: a } ,
1396
- dist:: Docs { stage : 2 , host: b } ,
1415
+ dist:: Docs { host: a } ,
1416
+ dist:: Docs { host: b } ,
1397
1417
]
1398
1418
) ;
1399
1419
assert_eq ! (
@@ -1410,7 +1430,7 @@ mod __test {
1410
1430
first( builder. cache. all:: <dist:: Std >( ) ) ,
1411
1431
& [
1412
1432
dist:: Std {
1413
- compiler: Compiler { host: a, stage: 2 } ,
1433
+ compiler: Compiler { host: a, stage: 1 } ,
1414
1434
target: a,
1415
1435
} ,
1416
1436
dist:: Std {
@@ -1434,8 +1454,8 @@ mod __test {
1434
1454
assert_eq ! (
1435
1455
first( builder. cache. all:: <dist:: Docs >( ) ) ,
1436
1456
& [
1437
- dist:: Docs { stage : 2 , host: a } ,
1438
- dist:: Docs { stage : 2 , host: b } ,
1457
+ dist:: Docs { host: a } ,
1458
+ dist:: Docs { host: b } ,
1439
1459
]
1440
1460
) ;
1441
1461
assert_eq ! (
@@ -1457,18 +1477,52 @@ mod __test {
1457
1477
first( builder. cache. all:: <dist:: Std >( ) ) ,
1458
1478
& [
1459
1479
dist:: Std {
1460
- compiler: Compiler { host: a, stage: 2 } ,
1480
+ compiler: Compiler { host: a, stage: 1 } ,
1461
1481
target: a,
1462
1482
} ,
1463
1483
dist:: Std {
1464
- compiler: Compiler { host: a, stage: 2 } ,
1484
+ compiler: Compiler { host: a, stage: 1 } ,
1465
1485
target: b,
1466
1486
} ,
1467
1487
]
1468
1488
) ;
1469
1489
assert_eq ! ( first( builder. cache. all:: <dist:: Src >( ) ) , & [ dist:: Src ] ) ;
1470
1490
}
1471
1491
1492
+ #[ test]
1493
+ fn dist_only_cross_host ( ) {
1494
+ let a = INTERNER . intern_str ( "A" ) ;
1495
+ let b = INTERNER . intern_str ( "B" ) ;
1496
+ let mut build = Build :: new ( configure ( & [ "B" ] , & [ ] ) ) ;
1497
+ build. config . docs = false ;
1498
+ build. config . extended = true ;
1499
+ build. hosts = vec ! [ b] ;
1500
+ let mut builder = Builder :: new ( & build) ;
1501
+ builder. run_step_descriptions ( & Builder :: get_step_descriptions ( Kind :: Dist ) , & [ ] ) ;
1502
+
1503
+ assert_eq ! (
1504
+ first( builder. cache. all:: <dist:: Rustc >( ) ) ,
1505
+ & [
1506
+ dist:: Rustc {
1507
+ compiler: Compiler { host: b, stage: 2 }
1508
+ } ,
1509
+ ]
1510
+ ) ;
1511
+ assert_eq ! (
1512
+ first( builder. cache. all:: <compile:: Rustc >( ) ) ,
1513
+ & [
1514
+ compile:: Rustc {
1515
+ compiler: Compiler { host: a, stage: 0 } ,
1516
+ target: a,
1517
+ } ,
1518
+ compile:: Rustc {
1519
+ compiler: Compiler { host: a, stage: 1 } ,
1520
+ target: b,
1521
+ } ,
1522
+ ]
1523
+ ) ;
1524
+ }
1525
+
1472
1526
#[ test]
1473
1527
fn dist_with_targets_and_hosts ( ) {
1474
1528
let build = Build :: new ( configure ( & [ "B" ] , & [ "C" ] ) ) ;
@@ -1482,9 +1536,9 @@ mod __test {
1482
1536
assert_eq ! (
1483
1537
first( builder. cache. all:: <dist:: Docs >( ) ) ,
1484
1538
& [
1485
- dist:: Docs { stage : 2 , host: a } ,
1486
- dist:: Docs { stage : 2 , host: b } ,
1487
- dist:: Docs { stage : 2 , host: c } ,
1539
+ dist:: Docs { host: a } ,
1540
+ dist:: Docs { host: b } ,
1541
+ dist:: Docs { host: c } ,
1488
1542
]
1489
1543
) ;
1490
1544
assert_eq ! (
@@ -1510,11 +1564,11 @@ mod __test {
1510
1564
first( builder. cache. all:: <dist:: Std >( ) ) ,
1511
1565
& [
1512
1566
dist:: Std {
1513
- compiler: Compiler { host: a, stage: 2 } ,
1567
+ compiler: Compiler { host: a, stage: 1 } ,
1514
1568
target: a,
1515
1569
} ,
1516
1570
dist:: Std {
1517
- compiler: Compiler { host: a, stage: 2 } ,
1571
+ compiler: Compiler { host: a, stage: 1 } ,
1518
1572
target: b,
1519
1573
} ,
1520
1574
dist:: Std {
@@ -1541,9 +1595,9 @@ mod __test {
1541
1595
assert_eq ! (
1542
1596
first( builder. cache. all:: <dist:: Docs >( ) ) ,
1543
1597
& [
1544
- dist:: Docs { stage : 2 , host: a } ,
1545
- dist:: Docs { stage : 2 , host: b } ,
1546
- dist:: Docs { stage : 2 , host: c } ,
1598
+ dist:: Docs { host: a } ,
1599
+ dist:: Docs { host: b } ,
1600
+ dist:: Docs { host: c } ,
1547
1601
]
1548
1602
) ;
1549
1603
assert_eq ! (
@@ -1559,11 +1613,11 @@ mod __test {
1559
1613
first( builder. cache. all:: <dist:: Std >( ) ) ,
1560
1614
& [
1561
1615
dist:: Std {
1562
- compiler: Compiler { host: a, stage: 2 } ,
1616
+ compiler: Compiler { host: a, stage: 1 } ,
1563
1617
target: a,
1564
1618
} ,
1565
1619
dist:: Std {
1566
- compiler: Compiler { host: a, stage: 2 } ,
1620
+ compiler: Compiler { host: a, stage: 1 } ,
1567
1621
target: b,
1568
1622
} ,
1569
1623
dist:: Std {
@@ -1587,8 +1641,8 @@ mod __test {
1587
1641
assert_eq ! (
1588
1642
first( builder. cache. all:: <dist:: Docs >( ) ) ,
1589
1643
& [
1590
- dist:: Docs { stage : 2 , host: a } ,
1591
- dist:: Docs { stage : 2 , host: b } ,
1644
+ dist:: Docs { host: a } ,
1645
+ dist:: Docs { host: b } ,
1592
1646
]
1593
1647
) ;
1594
1648
assert_eq ! (
@@ -1610,11 +1664,11 @@ mod __test {
1610
1664
first( builder. cache. all:: <dist:: Std >( ) ) ,
1611
1665
& [
1612
1666
dist:: Std {
1613
- compiler: Compiler { host: a, stage: 2 } ,
1667
+ compiler: Compiler { host: a, stage: 1 } ,
1614
1668
target: a,
1615
1669
} ,
1616
1670
dist:: Std {
1617
- compiler: Compiler { host: a, stage: 2 } ,
1671
+ compiler: Compiler { host: a, stage: 1 } ,
1618
1672
target: b,
1619
1673
} ,
1620
1674
]
@@ -1664,10 +1718,6 @@ mod __test {
1664
1718
compiler: Compiler { host: a, stage: 1 } ,
1665
1719
target: b,
1666
1720
} ,
1667
- compile:: Test {
1668
- compiler: Compiler { host: a, stage: 2 } ,
1669
- target: b,
1670
- } ,
1671
1721
]
1672
1722
) ;
1673
1723
assert_eq ! (
@@ -1720,10 +1770,6 @@ mod __test {
1720
1770
compiler: Compiler { host: b, stage: 2 } ,
1721
1771
target: a,
1722
1772
} ,
1723
- compile:: Rustc {
1724
- compiler: Compiler { host: a, stage: 0 } ,
1725
- target: b,
1726
- } ,
1727
1773
compile:: Rustc {
1728
1774
compiler: Compiler { host: a, stage: 1 } ,
1729
1775
target: b,
@@ -1758,10 +1804,6 @@ mod __test {
1758
1804
compiler: Compiler { host: b, stage: 2 } ,
1759
1805
target: a,
1760
1806
} ,
1761
- compile:: Test {
1762
- compiler: Compiler { host: a, stage: 0 } ,
1763
- target: b,
1764
- } ,
1765
1807
compile:: Test {
1766
1808
compiler: Compiler { host: a, stage: 1 } ,
1767
1809
target: b,
@@ -1808,9 +1850,6 @@ mod __test {
1808
1850
compile:: Assemble {
1809
1851
target_compiler: Compiler { host: a, stage: 1 } ,
1810
1852
} ,
1811
- compile:: Assemble {
1812
- target_compiler: Compiler { host: b, stage: 1 } ,
1813
- } ,
1814
1853
compile:: Assemble {
1815
1854
target_compiler: Compiler { host: a, stage: 2 } ,
1816
1855
} ,
@@ -1830,10 +1869,6 @@ mod __test {
1830
1869
compiler: Compiler { host: a, stage: 1 } ,
1831
1870
target: a,
1832
1871
} ,
1833
- compile:: Rustc {
1834
- compiler: Compiler { host: a, stage: 0 } ,
1835
- target: b,
1836
- } ,
1837
1872
compile:: Rustc {
1838
1873
compiler: Compiler { host: a, stage: 1 } ,
1839
1874
target: b,
@@ -1860,10 +1895,6 @@ mod __test {
1860
1895
compiler: Compiler { host: b, stage: 2 } ,
1861
1896
target: a,
1862
1897
} ,
1863
- compile:: Test {
1864
- compiler: Compiler { host: a, stage: 0 } ,
1865
- target: b,
1866
- } ,
1867
1898
compile:: Test {
1868
1899
compiler: Compiler { host: a, stage: 1 } ,
1869
1900
target: b,
0 commit comments