@@ -218,6 +218,9 @@ pub struct Build {
218218 /// User-specified configuration from `config.toml`.
219219 config : Config ,
220220
221+ // Version information
222+ version : String ,
223+
221224 // Properties derived from the above configuration
222225 src : PathBuf ,
223226 out : PathBuf ,
@@ -380,6 +383,10 @@ impl Build {
380383 . unwrap ( )
381384 . to_path_buf ( ) ;
382385
386+ let version = std:: fs:: read_to_string ( src. join ( "src" ) . join ( "version" ) )
387+ . expect ( "failed to read src/version" ) ;
388+ let version = version. trim ( ) ;
389+
383390 let mut build = Build {
384391 initial_rustc : config. initial_rustc . clone ( ) ,
385392 initial_cargo : config. initial_cargo . clone ( ) ,
@@ -395,6 +402,7 @@ impl Build {
395402 targets : config. targets . clone ( ) ,
396403
397404 config,
405+ version : version. to_string ( ) ,
398406 src,
399407 out,
400408
@@ -433,8 +441,7 @@ impl Build {
433441 . next ( )
434442 . unwrap ( )
435443 . trim ( ) ;
436- let my_version = channel:: CFG_RELEASE_NUM ;
437- if local_release. split ( '.' ) . take ( 2 ) . eq ( my_version. split ( '.' ) . take ( 2 ) ) {
444+ if local_release. split ( '.' ) . take ( 2 ) . eq ( version. split ( '.' ) . take ( 2 ) ) {
438445 build. verbose ( & format ! ( "auto-detected local-rebuild {}" , local_release) ) ;
439446 build. local_rebuild = true ;
440447 }
@@ -785,7 +792,7 @@ impl Build {
785792
786793 match which {
787794 GitRepo :: Rustc => {
788- let sha = self . rust_sha ( ) . unwrap_or ( channel :: CFG_RELEASE_NUM ) ;
795+ let sha = self . rust_sha ( ) . unwrap_or ( & self . version ) ;
789796 Some ( format ! ( "/rustc/{}" , sha) )
790797 }
791798 GitRepo :: Llvm => Some ( String :: from ( "/rustc/llvm" ) ) ,
@@ -1016,7 +1023,7 @@ impl Build {
10161023
10171024 /// Returns the value of `release` above for Rust itself.
10181025 fn rust_release ( & self ) -> String {
1019- self . release ( channel :: CFG_RELEASE_NUM )
1026+ self . release ( & self . version )
10201027 }
10211028
10221029 /// Returns the "package version" for a component given the `num` release
@@ -1036,7 +1043,7 @@ impl Build {
10361043
10371044 /// Returns the value of `package_vers` above for Rust itself.
10381045 fn rust_package_vers ( & self ) -> String {
1039- self . package_vers ( channel :: CFG_RELEASE_NUM )
1046+ self . package_vers ( & self . version )
10401047 }
10411048
10421049 /// Returns the value of `package_vers` above for Cargo
@@ -1070,7 +1077,7 @@ impl Build {
10701077 }
10711078
10721079 fn llvm_tools_package_vers ( & self ) -> String {
1073- self . package_vers ( channel :: CFG_RELEASE_NUM )
1080+ self . package_vers ( & self . version )
10741081 }
10751082
10761083 fn llvm_tools_vers ( & self ) -> String {
@@ -1087,7 +1094,7 @@ impl Build {
10871094 /// Note that this is a descriptive string which includes the commit date,
10881095 /// sha, version, etc.
10891096 fn rust_version ( & self ) -> String {
1090- self . rust_info . version ( self , channel :: CFG_RELEASE_NUM )
1097+ self . rust_info . version ( self , & self . version )
10911098 }
10921099
10931100 /// Returns the full commit hash.
0 commit comments