@@ -1380,21 +1380,46 @@ impl Config {
13801380 git
13811381 }
13821382
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 ( ) {
13851387 let mut channel = self . git ( ) ;
13861388 channel. arg ( "show" ) . arg ( format ! ( "{}:src/ci/channel" , commit) ) ;
13871389 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 ( ) )
13911394 } 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) ,
13981423 }
13991424 }
14001425
@@ -1637,7 +1662,7 @@ fn maybe_download_rustfmt(builder: &Builder<'_>) -> Option<PathBuf> {
16371662
16381663fn download_ci_rustc ( builder : & Builder < ' _ > , commit : & str ) {
16391664 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) ;
16411666 let host = builder. config . build . triple ;
16421667 let bin_root = builder. out . join ( host) . join ( "ci-rustc" ) ;
16431668 let rustc_stamp = bin_root. join ( ".rustc-stamp" ) ;
@@ -1646,13 +1671,13 @@ fn download_ci_rustc(builder: &Builder<'_>, commit: &str) {
16461671 if bin_root. exists ( ) {
16471672 t ! ( fs:: remove_dir_all( & bin_root) ) ;
16481673 }
1649- let filename = format ! ( "rust-std-{channel }-{host}.tar.xz" ) ;
1674+ let filename = format ! ( "rust-std-{version }-{host}.tar.xz" ) ;
16501675 let pattern = format ! ( "rust-std-{host}" ) ;
16511676 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" ) ;
16531678 download_ci_component ( builder, filename, "rustc" , commit) ;
16541679 // 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" ) ;
16561681 download_ci_component ( builder, filename, "rustc-dev" , commit) ;
16571682
16581683 builder. fix_bin_or_dylib ( & bin_root. join ( "bin" ) . join ( "rustc" ) ) ;
0 commit comments