@@ -25,7 +25,7 @@ use crate::core::build_steps::llvm;
2525use crate :: core:: build_steps:: tool:: { self , Tool } ;
2626use crate :: core:: builder:: { Builder , Kind , RunConfig , ShouldRun , Step } ;
2727use crate :: core:: config:: TargetSelection ;
28- use crate :: utils:: channel;
28+ use crate :: utils:: channel:: { self , Info } ;
2929use crate :: utils:: helpers:: { exe, is_dylib, output, t, target_supports_cranelift_backend, timeit} ;
3030use crate :: utils:: tarball:: { GeneratedTarball , OverlayKind , Tarball } ;
3131use crate :: { Compiler , DependencyType , Mode , LLVM_TOOLS } ;
@@ -991,10 +991,17 @@ impl Step for PlainSourceTarball {
991991
992992 // Create the version file
993993 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" ) ) ;
9981005
9991006 // If we're building from git or tarball sources, we need to vendor
10001007 // a complete distribution.
0 commit comments