From a8261333e12bb64a4f2071a0c320d583b9f083da Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Sun, 27 Oct 2024 08:38:20 +0300 Subject: [PATCH 1/2] don't use absolute paths on `git(Some(self.src))` It will run at the project root, so resolving absolute/top-level paths is unnecessary. Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/compile.rs | 2 +- src/bootstrap/src/core/config/config.rs | 9 +-------- src/bootstrap/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 27bbc8bd8ff..893fa9f79cb 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -135,7 +135,7 @@ fn make_run(run: RunConfig<'_>) { !t!(helpers::git(Some(&builder.src)) .args(["diff-index", "--quiet", &closest_merge_commit]) .arg("--") - .arg(builder.src.join("library")) + .arg("library") .as_command_mut() .status()) .success() diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 087dde0d9c6..139ca7eb52e 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -2871,14 +2871,7 @@ pub fn last_modified_commit( // 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 { diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index a9db0377a50..ba74cabcd30 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -541,7 +541,7 @@ fn update_existing_submodules(&self) { } 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(); From 74bfa661a5abc8b485248fa7f17e1a7104dc2fb0 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Sun, 27 Oct 2024 08:55:52 +0300 Subject: [PATCH 2/2] simplify force-recompile logic for "library" Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/compile.rs | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 893fa9f79cb..e13d4ccc618 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -15,7 +15,6 @@ 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; @@ -27,7 +26,7 @@ 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}; @@ -125,23 +124,9 @@ fn make_run(run: RunConfig<'_>) { // 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("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()),