@@ -14,7 +14,6 @@ use std::path::{Path, PathBuf};
14
14
use std:: sync:: OnceLock ;
15
15
use std:: { env, fs} ;
16
16
17
- use build_helper:: ci:: CiEnv ;
18
17
use build_helper:: git:: get_closest_merge_commit;
19
18
#[ cfg( feature = "tracing" ) ]
20
19
use tracing:: instrument;
@@ -174,20 +173,19 @@ pub fn prebuilt_llvm_config(
174
173
LlvmBuildStatus :: ShouldBuild ( Meta { stamp, res, out_dir, root : root. into ( ) } )
175
174
}
176
175
176
+ /// Paths whose changes invalidate LLVM downloads.
177
+ pub const LLVM_INVALIDATION_PATHS : & [ & str ] = & [
178
+ "src/llvm-project" ,
179
+ "src/bootstrap/download-ci-llvm-stamp" ,
180
+ // the LLVM shared object file is named `LLVM-<LLVM-version>-rust-{version}-nightly`
181
+ "src/version" ,
182
+ ] ;
183
+
177
184
/// This retrieves the LLVM sha we *want* to use, according to git history.
178
185
pub ( crate ) fn detect_llvm_sha ( config : & Config , is_git : bool ) -> String {
179
186
let llvm_sha = if is_git {
180
- get_closest_merge_commit (
181
- Some ( & config. src ) ,
182
- & config. git_config ( ) ,
183
- & [
184
- config. src . join ( "src/llvm-project" ) ,
185
- config. src . join ( "src/bootstrap/download-ci-llvm-stamp" ) ,
186
- // the LLVM shared object file is named `LLVM-12-rust-{version}-nightly`
187
- config. src . join ( "src/version" ) ,
188
- ] ,
189
- )
190
- . unwrap ( )
187
+ get_closest_merge_commit ( Some ( & config. src ) , & config. git_config ( ) , LLVM_INVALIDATION_PATHS )
188
+ . unwrap ( )
191
189
} else if let Some ( info) = crate :: utils:: channel:: read_commit_info_file ( & config. src ) {
192
190
info. sha . trim ( ) . to_owned ( )
193
191
} else {
@@ -207,10 +205,9 @@ pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String {
207
205
208
206
/// Returns whether the CI-found LLVM is currently usable.
209
207
///
210
- /// This checks both the build triple platform to confirm we're usable at all,
211
- /// and then verifies if the current HEAD matches the detected LLVM SHA head,
212
- /// in which case LLVM is indicated as not available.
213
- pub ( crate ) fn is_ci_llvm_available ( config : & Config , asserts : bool ) -> bool {
208
+ /// This checks the build triple platform to confirm we're usable at all, and if LLVM
209
+ /// with/without assertions is available.
210
+ pub ( crate ) fn is_ci_llvm_available_for_target ( config : & Config , asserts : bool ) -> bool {
214
211
// This is currently all tier 1 targets and tier 2 targets with host tools
215
212
// (since others may not have CI artifacts)
216
213
// https://doc.rust-lang.org/rustc/platform-support.html#tier-1
@@ -255,41 +252,9 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
255
252
return false ;
256
253
}
257
254
258
- if is_ci_llvm_modified ( config) {
259
- eprintln ! ( "Detected LLVM as non-available: running in CI and modified LLVM in this change" ) ;
260
- return false ;
261
- }
262
-
263
255
true
264
256
}
265
257
266
- /// Returns true if we're running in CI with modified LLVM (and thus can't download it)
267
- pub ( crate ) fn is_ci_llvm_modified ( config : & Config ) -> bool {
268
- // If not running in a CI environment, return false.
269
- if !config. is_running_on_ci {
270
- return false ;
271
- }
272
-
273
- // In rust-lang/rust managed CI, assert the existence of the LLVM submodule.
274
- if CiEnv :: is_rust_lang_managed_ci_job ( ) {
275
- assert ! (
276
- config. in_tree_llvm_info. is_managed_git_subrepository( ) ,
277
- "LLVM submodule must be fetched in rust-lang/rust managed CI builders."
278
- ) ;
279
- }
280
- // If LLVM submodule isn't present, skip the change check as it won't work.
281
- else if !config. in_tree_llvm_info . is_managed_git_subrepository ( ) {
282
- return false ;
283
- }
284
-
285
- let llvm_sha = detect_llvm_sha ( config, true ) ;
286
- let head_sha = crate :: output (
287
- helpers:: git ( Some ( & config. src ) ) . arg ( "rev-parse" ) . arg ( "HEAD" ) . as_command_mut ( ) ,
288
- ) ;
289
- let head_sha = head_sha. trim ( ) ;
290
- llvm_sha == head_sha
291
- }
292
-
293
258
#[ derive( Debug , Clone , Hash , PartialEq , Eq ) ]
294
259
pub struct Llvm {
295
260
pub target : TargetSelection ,
0 commit comments