Skip to content

Commit 975ba58

Browse files
committed
Use the existing LLVM GitInfo for checking rebuilds
1 parent 6c49da4 commit 975ba58

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

src/bootstrap/native.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,45 +67,38 @@ impl Step for Llvm {
6767
}
6868
}
6969

70-
let (submodule, root, out_dir, llvm_config_ret_dir) = if emscripten {
70+
let (llvm_commit, root, out_dir, llvm_config_ret_dir) = if emscripten {
71+
let sha = builder.build.emscripten_llvm_info.sha();
7172
let dir = builder.emscripten_llvm_out(target);
7273
let config_dir = dir.join("bin");
73-
("src/llvm-emscripten", "src/llvm-emscripten", dir, config_dir)
74+
(sha, "src/llvm-emscripten", dir, config_dir)
7475
} else {
76+
let sha = builder.build.in_tree_llvm_info.sha();
7577
let mut dir = builder.llvm_out(builder.config.build);
7678
if !builder.config.build.contains("msvc") || builder.config.ninja {
7779
dir.push("build");
7880
}
79-
("src/llvm-project", "src/llvm-project/llvm", builder.llvm_out(target), dir.join("bin"))
81+
(sha, "src/llvm-project/llvm", builder.llvm_out(target), dir.join("bin"))
8082
};
8183

82-
let git_output = t!(Command::new("git")
83-
.args(&["rev-parse", "--verify", &format!("@:./{}", submodule)])
84-
.current_dir(&builder.src)
85-
.output());
86-
87-
let llvm_commit = if git_output.status.success() {
88-
Some(git_output.stdout)
89-
} else {
84+
if llvm_commit.is_none() {
9085
println!(
91-
"git could not determine the LLVM submodule commit hash ({}). \
86+
"git could not determine the LLVM submodule commit hash. \
9287
Assuming that an LLVM build is necessary.",
93-
String::from_utf8_lossy(&git_output.stderr),
9488
);
95-
None
96-
};
89+
}
9790

9891
let build_llvm_config = llvm_config_ret_dir
9992
.join(exe("llvm-config", &*builder.config.build));
10093
let done_stamp = out_dir.join("llvm-finished-building");
10194

102-
if let Some(llvm_commit) = &llvm_commit {
95+
if let Some(llvm_commit) = llvm_commit {
10396
if done_stamp.exists() {
10497
let done_contents = t!(fs::read(&done_stamp));
10598

10699
// If LLVM was already built previously and the submodule's commit didn't change
107100
// from the previous build, then no action is required.
108-
if done_contents == llvm_commit.as_slice() {
101+
if done_contents == llvm_commit.as_bytes() {
109102
return build_llvm_config
110103
}
111104
}
@@ -296,7 +289,7 @@ impl Step for Llvm {
296289
cfg.build();
297290

298291
if let Some(llvm_commit) = llvm_commit {
299-
t!(fs::write(&done_stamp, &llvm_commit));
292+
t!(fs::write(&done_stamp, llvm_commit));
300293
}
301294

302295
build_llvm_config

0 commit comments

Comments
 (0)