@@ -25,7 +25,7 @@ use crate::core::build_steps::llvm;
25
25
use crate :: core:: build_steps:: tool:: { self , Tool } ;
26
26
use crate :: core:: builder:: { Builder , Kind , RunConfig , ShouldRun , Step } ;
27
27
use crate :: core:: config:: TargetSelection ;
28
- use crate :: utils:: channel;
28
+ use crate :: utils:: channel:: { self , Info } ;
29
29
use crate :: utils:: helpers:: { exe, is_dylib, output, t, target_supports_cranelift_backend, timeit} ;
30
30
use crate :: utils:: tarball:: { GeneratedTarball , OverlayKind , Tarball } ;
31
31
use crate :: { Compiler , DependencyType , Mode , LLVM_TOOLS } ;
@@ -991,10 +991,17 @@ impl Step for PlainSourceTarball {
991
991
992
992
// Create the version file
993
993
builder. create ( & plain_dst_src. join ( "version" ) , & builder. rust_version ( ) ) ;
994
- if let Some ( info) = builder. rust_info ( ) . info ( ) {
995
- channel:: write_commit_hash_file ( plain_dst_src, & info. sha ) ;
996
- channel:: write_commit_info_file ( plain_dst_src, info) ;
997
- }
994
+
995
+ // Create the files containing git info, to ensure --version outputs the same.
996
+ let write_git_info = |info : Option < & Info > , path : & Path | {
997
+ if let Some ( info) = info {
998
+ t ! ( std:: fs:: create_dir_all( path) ) ;
999
+ channel:: write_commit_hash_file ( path, & info. sha ) ;
1000
+ channel:: write_commit_info_file ( path, info) ;
1001
+ }
1002
+ } ;
1003
+ write_git_info ( builder. rust_info ( ) . info ( ) , plain_dst_src) ;
1004
+ write_git_info ( builder. cargo_info . info ( ) , & plain_dst_src. join ( "./src/tools/cargo" ) ) ;
998
1005
999
1006
// If we're building from git or tarball sources, we need to vendor
1000
1007
// a complete distribution.
0 commit comments