Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c07c957

Browse files
committed
WIP: SHA check
1 parent 517fa87 commit c07c957

File tree

3 files changed

+69
-37
lines changed

3 files changed

+69
-37
lines changed

src/bootstrap/src/core/config/config.rs

Lines changed: 67 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use std::{cmp, env, fs};
1515

1616
use build_helper::ci::CiEnv;
1717
use build_helper::exit;
18-
use build_helper::git::{GitConfig, PathFreshness, check_path_modifications, output_result};
18+
use build_helper::git::{
19+
GitConfig, PathFreshness, check_path_modifications, get_closest_merge_commit, output_result,
20+
};
1921
use serde::{Deserialize, Deserializer};
2022
use serde_derive::Deserialize;
2123
#[cfg(feature = "tracing")]
@@ -3020,41 +3022,70 @@ impl Config {
30203022
asserts: bool,
30213023
) -> bool {
30223024
let download_ci_llvm = download_ci_llvm.unwrap_or(StringOrBool::Bool(true));
3023-
3024-
let if_unchanged = || {
3025-
if self.rust_info.is_from_tarball() {
3026-
// Git is needed for running "if-unchanged" logic.
3027-
println!("ERROR: 'if-unchanged' is only compatible with Git managed sources.");
3028-
crate::exit!(1);
3029-
}
3030-
3031-
// Fetching the LLVM submodule is unnecessary for self-tests.
3032-
#[cfg(not(test))]
3033-
self.update_submodule("src/llvm-project");
3034-
3035-
// Check for untracked changes in `src/llvm-project`.
3036-
let has_changes = self.has_changes_from_upstream(&["src/llvm-project"]);
3037-
3038-
// Return false if there are untracked changes, otherwise check if CI LLVM is available.
3039-
if has_changes { false } else { llvm::is_ci_llvm_available(self, asserts) }
3040-
};
3041-
3042-
match download_ci_llvm {
3043-
StringOrBool::Bool(b) => {
3044-
if !b && self.download_rustc_commit.is_some() {
3045-
panic!(
3046-
"`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`."
3047-
);
3048-
}
3049-
3050-
// If download-ci-llvm=true we also want to check that CI llvm is available
3051-
b && llvm::is_ci_llvm_available(self, asserts)
3052-
}
3053-
StringOrBool::String(s) if s == "if-unchanged" => if_unchanged(),
3054-
StringOrBool::String(other) => {
3055-
panic!("unrecognized option for download-ci-llvm: {:?}", other)
3056-
}
3057-
}
3025+
let freshness = self.check_modifications(&[
3026+
"src/llvm-project",
3027+
"src/bootstrap/download-ci-llvm-stamp",
3028+
"src/version",
3029+
]);
3030+
let sha = get_closest_merge_commit(
3031+
Some(&self.src),
3032+
&self.git_config(),
3033+
&[
3034+
self.src.join("src/llvm-project"),
3035+
self.src.join("src/bootstrap/download-ci-llvm-stamp"),
3036+
// the LLVM shared object file is named `LLVM-12-rust-{version}-nightly`
3037+
self.src.join("src/version"),
3038+
],
3039+
)
3040+
.unwrap();
3041+
let head = String::from_utf8(
3042+
Command::new("git")
3043+
.current_dir(&self.src)
3044+
.arg("rev-parse")
3045+
.arg("HEAD")
3046+
.output()
3047+
.unwrap()
3048+
.stdout,
3049+
)
3050+
.unwrap()
3051+
.trim()
3052+
.to_string();
3053+
panic!("LLVM FRESHNESS: {freshness:?}\nOld git SHA: {sha}\nHEAD: {head}");
3054+
//
3055+
// let if_unchanged = || {
3056+
// if self.rust_info.is_from_tarball() {
3057+
// // Git is needed for running "if-unchanged" logic.
3058+
// println!("ERROR: 'if-unchanged' is only compatible with Git managed sources.");
3059+
// crate::exit!(1);
3060+
// }
3061+
//
3062+
// // Fetching the LLVM submodule is unnecessary for self-tests.
3063+
// #[cfg(not(test))]
3064+
// self.update_submodule("src/llvm-project");
3065+
//
3066+
// // Check for untracked changes in `src/llvm-project`.
3067+
// let has_changes = self.has_changes_from_upstream(&["src/llvm-project"]);
3068+
//
3069+
// // Return false if there are untracked changes, otherwise check if CI LLVM is available.
3070+
// if has_changes { false } else { llvm::is_ci_llvm_available(self, asserts) }
3071+
// };
3072+
//
3073+
// match download_ci_llvm {
3074+
// StringOrBool::Bool(b) => {
3075+
// if !b && self.download_rustc_commit.is_some() {
3076+
// panic!(
3077+
// "`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`."
3078+
// );
3079+
// }
3080+
//
3081+
// // If download-ci-llvm=true we also want to check that CI llvm is available
3082+
// b && llvm::is_ci_llvm_available(self, asserts)
3083+
// }
3084+
// StringOrBool::String(s) if s == "if-unchanged" => if_unchanged(),
3085+
// StringOrBool::String(other) => {
3086+
// panic!("unrecognized option for download-ci-llvm: {:?}", other)
3087+
// }
3088+
// }
30583089
}
30593090

30603091
/// Returns true if any of the `paths` have been modified locally.

src/bootstrap/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(unused)]
12
//! Implementation of bootstrap, the Rust build system.
23
//!
34
//! This module, and its descendants, are the implementation of the Rust build

src/build_helper/src/git.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(test)]
22
mod tests;
33

4-
use std::path::Path;
4+
use std::path::{Path, PathBuf};
55
use std::process::{Command, Stdio};
66

77
use crate::ci::CiEnv;

0 commit comments

Comments
 (0)