@@ -15,7 +15,9 @@ use std::{cmp, env, fs};
15
15
16
16
use build_helper:: ci:: CiEnv ;
17
17
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
+ } ;
19
21
use serde:: { Deserialize , Deserializer } ;
20
22
use serde_derive:: Deserialize ;
21
23
#[ cfg( feature = "tracing" ) ]
@@ -3020,41 +3022,70 @@ impl Config {
3020
3022
asserts : bool ,
3021
3023
) -> bool {
3022
3024
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:?}\n Old git SHA: {sha}\n HEAD: {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
+ // }
3058
3089
}
3059
3090
3060
3091
/// Returns true if any of the `paths` have been modified locally.
0 commit comments