Skip to content

Commit 5f5c243

Browse files
committed
Auto merge of #132215 - onur-ozkan:bootstrap-git, r=Kobzol
simplify force-recompile logic for "library" It’s kind of self-explanatory when looking at it commit by commit.
2 parents 9fa0146 + 74bfa66 commit 5f5c243

File tree

3 files changed

+6
-28
lines changed

3 files changed

+6
-28
lines changed

Diff for: src/bootstrap/src/core/build_steps/compile.rs

+4-19
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use std::path::{Path, PathBuf};
1515
use std::process::Stdio;
1616
use std::{env, fs, str};
1717

18-
use build_helper::git::get_closest_merge_commit;
1918
use serde_derive::Deserialize;
2019

2120
use crate::core::build_steps::tool::SourceType;
@@ -27,7 +26,7 @@ use crate::core::builder::{
2726
use crate::core::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection};
2827
use crate::utils::exec::command;
2928
use crate::utils::helpers::{
30-
self, exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
29+
exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
3130
};
3231
use crate::{CLang, Compiler, DependencyType, GitRepo, LLVM_TOOLS, Mode};
3332

@@ -125,23 +124,9 @@ impl Step for Std {
125124
// Force compilation of the standard library from source if the `library` is modified. This allows
126125
// library team to compile the standard library without needing to compile the compiler with
127126
// the `rust.download-rustc=true` option.
128-
let force_recompile =
129-
if builder.rust_info().is_managed_git_subrepository() && builder.download_rustc() {
130-
let closest_merge_commit =
131-
get_closest_merge_commit(Some(&builder.src), &builder.config.git_config(), &[])
132-
.unwrap();
133-
134-
// Check if `library` has changes (returns false otherwise)
135-
!t!(helpers::git(Some(&builder.src))
136-
.args(["diff-index", "--quiet", &closest_merge_commit])
137-
.arg("--")
138-
.arg(builder.src.join("library"))
139-
.as_command_mut()
140-
.status())
141-
.success()
142-
} else {
143-
false
144-
};
127+
let force_recompile = builder.rust_info().is_managed_git_subrepository()
128+
&& builder.download_rustc()
129+
&& builder.config.last_modified_commit(&["library"], "download-rustc", true).is_none();
145130

146131
run.builder.ensure(Std {
147132
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),

Diff for: src/bootstrap/src/core/config/config.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -2871,14 +2871,7 @@ impl Config {
28712871

28722872
// Warn if there were changes to the compiler or standard library since the ancestor commit.
28732873
let mut git = helpers::git(Some(&self.src));
2874-
git.args(["diff-index", "--quiet", &commit, "--"]);
2875-
2876-
// Handle running from a directory other than the top level
2877-
let top_level = &self.src;
2878-
2879-
for path in modified_paths {
2880-
git.arg(top_level.join(path));
2881-
}
2874+
git.args(["diff-index", "--quiet", &commit, "--"]).args(modified_paths);
28822875

28832876
let has_changes = !t!(git.as_command_mut().status()).success();
28842877
if has_changes {

Diff for: src/bootstrap/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ impl Build {
541541
}
542542
let output = helpers::git(Some(&self.src))
543543
.args(["config", "--file"])
544-
.arg(self.config.src.join(".gitmodules"))
544+
.arg(".gitmodules")
545545
.args(["--get-regexp", "path"])
546546
.run_capture(self)
547547
.stdout();

0 commit comments

Comments
 (0)