Skip to content

Commit ae1ca39

Browse files
authored
Unrolled build for rust-lang#124553
Rollup merge of rust-lang#124553 - ferrocene:pa-cargo-git-info, r=onur-ozkan Write `git-commit-{sha,info}` for Cargo in source tarballs Right now Cargo doesn't populate the commit hash or date in its version output when it's built from the plain source tarball. That's because we don't include the git information for it, and Cargo's build script doesn't pick it up. This PR *partially* solves the problem by storing the git information for Cargo in `src/tools/cargo` in the plain source tarball. We store separate information because even when built in CI Cargo uses its own git information rather than Rust's. This PR will also require a change in the Cargo repository to consume this information (rust-lang/cargo#13832), but it doesn't have to be blocked on the Cargo PR being merged.
2 parents 20aa2d8 + 7a5038f commit ae1ca39

File tree

1 file changed

+12
-5
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+12
-5
lines changed

src/bootstrap/src/core/build_steps/dist.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::core::build_steps::llvm;
2525
use crate::core::build_steps::tool::{self, Tool};
2626
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
2727
use crate::core::config::TargetSelection;
28-
use crate::utils::channel;
28+
use crate::utils::channel::{self, Info};
2929
use crate::utils::helpers::{exe, is_dylib, output, t, target_supports_cranelift_backend, timeit};
3030
use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball};
3131
use 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

Comments
 (0)