Skip to content

Commit

Permalink
Auto merge of #132215 - onur-ozkan:bootstrap-git, r=Kobzol
Browse files Browse the repository at this point in the history
simplify force-recompile logic for "library"

It’s kind of self-explanatory when looking at it commit by commit.
  • Loading branch information
bors committed Oct 27, 2024
2 parents 9fa0146 + 74bfa66 commit 5f5c243
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 28 deletions.
23 changes: 4 additions & 19 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use std::path::{Path, PathBuf};
use std::process::Stdio;
use std::{env, fs, str};

use build_helper::git::get_closest_merge_commit;
use serde_derive::Deserialize;

use crate::core::build_steps::tool::SourceType;
Expand All @@ -27,7 +26,7 @@ use crate::core::builder::{
use crate::core::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection};
use crate::utils::exec::command;
use crate::utils::helpers::{
self, exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
};
use crate::{CLang, Compiler, DependencyType, GitRepo, LLVM_TOOLS, Mode};

Expand Down Expand Up @@ -125,23 +124,9 @@ impl Step for Std {
// Force compilation of the standard library from source if the `library` is modified. This allows
// library team to compile the standard library without needing to compile the compiler with
// the `rust.download-rustc=true` option.
let force_recompile =
if builder.rust_info().is_managed_git_subrepository() && builder.download_rustc() {
let closest_merge_commit =
get_closest_merge_commit(Some(&builder.src), &builder.config.git_config(), &[])
.unwrap();

// Check if `library` has changes (returns false otherwise)
!t!(helpers::git(Some(&builder.src))
.args(["diff-index", "--quiet", &closest_merge_commit])
.arg("--")
.arg(builder.src.join("library"))
.as_command_mut()
.status())
.success()
} else {
false
};
let force_recompile = builder.rust_info().is_managed_git_subrepository()
&& builder.download_rustc()
&& builder.config.last_modified_commit(&["library"], "download-rustc", true).is_none();

run.builder.ensure(Std {
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
Expand Down
9 changes: 1 addition & 8 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2871,14 +2871,7 @@ impl Config {

// Warn if there were changes to the compiler or standard library since the ancestor commit.
let mut git = helpers::git(Some(&self.src));
git.args(["diff-index", "--quiet", &commit, "--"]);

// Handle running from a directory other than the top level
let top_level = &self.src;

for path in modified_paths {
git.arg(top_level.join(path));
}
git.args(["diff-index", "--quiet", &commit, "--"]).args(modified_paths);

let has_changes = !t!(git.as_command_mut().status()).success();
if has_changes {
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ impl Build {
}
let output = helpers::git(Some(&self.src))
.args(["config", "--file"])
.arg(self.config.src.join(".gitmodules"))
.arg(".gitmodules")
.args(["--get-regexp", "path"])
.run_capture(self)
.stdout();
Expand Down

0 comments on commit 5f5c243

Please sign in to comment.