@@ -1380,21 +1380,46 @@ impl Config {
1380
1380
git
1381
1381
}
1382
1382
1383
- pub ( crate ) fn artifact_channel ( & self , builder : & Builder < ' _ > , commit : & str ) -> String {
1384
- if builder. rust_info . is_managed_git_subrepository ( ) {
1383
+ /// Bootstrap embeds a version number into the name of shared libraries it uploads in CI.
1384
+ /// Return the version it would have used for the given commit.
1385
+ pub ( crate ) fn artifact_version_part ( & self , builder : & Builder < ' _ > , commit : & str ) -> String {
1386
+ let ( channel, version) = if builder. rust_info . is_managed_git_subrepository ( ) {
1385
1387
let mut channel = self . git ( ) ;
1386
1388
channel. arg ( "show" ) . arg ( format ! ( "{}:src/ci/channel" , commit) ) ;
1387
1389
let channel = output ( & mut channel) ;
1388
- channel. trim ( ) . to_owned ( )
1389
- } else if let Ok ( channel) = fs:: read_to_string ( builder. src . join ( "src/ci/channel" ) ) {
1390
- channel. trim ( ) . to_owned ( )
1390
+ let mut version = self . git ( ) ;
1391
+ version. arg ( "show" ) . arg ( format ! ( "{}:src/version" , commit) ) ;
1392
+ let version = output ( & mut version) ;
1393
+ ( channel. trim ( ) . to_owned ( ) , version. trim ( ) . to_owned ( ) )
1391
1394
} else {
1392
- let src = builder. src . display ( ) ;
1393
- eprintln ! ( "error: failed to determine artifact channel" ) ;
1394
- eprintln ! (
1395
- "help: either use git or ensure that {src}/src/ci/channel contains the name of the channel to use"
1396
- ) ;
1397
- panic ! ( ) ;
1395
+ let channel = fs:: read_to_string ( builder. src . join ( "src/ci/channel" ) ) ;
1396
+ let version = fs:: read_to_string ( builder. src . join ( "src/version" ) ) ;
1397
+ match ( channel, version) {
1398
+ ( Ok ( channel) , Ok ( version) ) => {
1399
+ ( channel. trim ( ) . to_owned ( ) , version. trim ( ) . to_owned ( ) )
1400
+ }
1401
+ ( channel, version) => {
1402
+ let src = builder. src . display ( ) ;
1403
+ eprintln ! ( "error: failed to determine artifact channel and/or version" ) ;
1404
+ eprintln ! (
1405
+ "help: consider using a git checkout or ensure these files are readable"
1406
+ ) ;
1407
+ if let Err ( channel) = channel {
1408
+ eprintln ! ( "reading {}/src/ci/channel failed: {:?}" , src, channel) ;
1409
+ }
1410
+ if let Err ( version) = version {
1411
+ eprintln ! ( "reading {}/src/version failed: {:?}" , src, version) ;
1412
+ }
1413
+ panic ! ( ) ;
1414
+ }
1415
+ }
1416
+ } ;
1417
+
1418
+ match channel. as_str ( ) {
1419
+ "stable" => version,
1420
+ "beta" => channel,
1421
+ "nightly" => channel,
1422
+ other => unreachable ! ( "{:?} is not recognized as a valid channel" , other) ,
1398
1423
}
1399
1424
}
1400
1425
@@ -1637,7 +1662,7 @@ fn maybe_download_rustfmt(builder: &Builder<'_>) -> Option<PathBuf> {
1637
1662
1638
1663
fn download_ci_rustc ( builder : & Builder < ' _ > , commit : & str ) {
1639
1664
builder. verbose ( & format ! ( "using downloaded stage2 artifacts from CI (commit {commit})" ) ) ;
1640
- let channel = builder. config . artifact_channel ( builder, commit) ;
1665
+ let version = builder. config . artifact_version_part ( builder, commit) ;
1641
1666
let host = builder. config . build . triple ;
1642
1667
let bin_root = builder. out . join ( host) . join ( "ci-rustc" ) ;
1643
1668
let rustc_stamp = bin_root. join ( ".rustc-stamp" ) ;
@@ -1646,13 +1671,13 @@ fn download_ci_rustc(builder: &Builder<'_>, commit: &str) {
1646
1671
if bin_root. exists ( ) {
1647
1672
t ! ( fs:: remove_dir_all( & bin_root) ) ;
1648
1673
}
1649
- let filename = format ! ( "rust-std-{channel }-{host}.tar.xz" ) ;
1674
+ let filename = format ! ( "rust-std-{version }-{host}.tar.xz" ) ;
1650
1675
let pattern = format ! ( "rust-std-{host}" ) ;
1651
1676
download_ci_component ( builder, filename, & pattern, commit) ;
1652
- let filename = format ! ( "rustc-{channel }-{host}.tar.xz" ) ;
1677
+ let filename = format ! ( "rustc-{version }-{host}.tar.xz" ) ;
1653
1678
download_ci_component ( builder, filename, "rustc" , commit) ;
1654
1679
// download-rustc doesn't need its own cargo, it can just use beta's.
1655
- let filename = format ! ( "rustc-dev-{channel }-{host}.tar.xz" ) ;
1680
+ let filename = format ! ( "rustc-dev-{version }-{host}.tar.xz" ) ;
1656
1681
download_ci_component ( builder, filename, "rustc-dev" , commit) ;
1657
1682
1658
1683
builder. fix_bin_or_dylib ( & bin_root. join ( "bin" ) . join ( "rustc" ) ) ;
0 commit comments