Skip to content

Commit a68bad1

Browse files
committed
Auto merge of #131455 - onur-ozkan:debug, r=<try>
debug **DO NOT MERGE** try-build: aarch64-apple
2 parents a1eceec + df445b9 commit a68bad1

File tree

5 files changed

+53
-15
lines changed

5 files changed

+53
-15
lines changed

compiler/rustc_serialize/src/serialize.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl<D: Decoder, const N: usize> Decodable<D> for [u8; N] {
325325
}
326326
}
327327

328-
impl<'a, S: Encoder, T: Encodable<S>> Encodable<S> for Cow<'a, [T]>
328+
impl<S: Encoder, T: Encodable<S>> Encodable<S> for Cow<'_, [T]>
329329
where
330330
[T]: ToOwned<Owned = Vec<T>>,
331331
{
@@ -345,14 +345,14 @@ where
345345
}
346346
}
347347

348-
impl<'a, S: Encoder> Encodable<S> for Cow<'a, str> {
348+
impl<S: Encoder> Encodable<S> for Cow<'_, str> {
349349
fn encode(&self, s: &mut S) {
350350
let val: &str = self;
351351
val.encode(s)
352352
}
353353
}
354354

355-
impl<'a, D: Decoder> Decodable<D> for Cow<'a, str> {
355+
impl<D: Decoder> Decodable<D> for Cow<'_, str> {
356356
fn decode(d: &mut D) -> Cow<'static, str> {
357357
let v: String = Decodable::decode(d);
358358
Cow::Owned(v)

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ use build_helper::git::get_closest_merge_commit;
2020

2121
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
2222
use crate::core::config::{Config, TargetSelection};
23-
use crate::utils::channel;
2423
use crate::utils::exec::command;
2524
use crate::utils::helpers::{
26-
self, HashStamp, exe, get_clang_cl_resource_dir, output, t, unhashed_basename, up_to_date,
25+
self, HashStamp, exe, get_clang_cl_resource_dir, t, unhashed_basename, up_to_date,
2726
};
2827
use crate::{CLang, GitRepo, Kind, generate_smart_stamp_hash};
2928

@@ -157,6 +156,7 @@ pub fn prebuilt_llvm_config(
157156
}
158157

159158
/// This retrieves the LLVM sha we *want* to use, according to git history.
159+
#[cfg(not(feature = "bootstrap-self-test"))]
160160
pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String {
161161
let llvm_sha = if is_git {
162162
get_closest_merge_commit(Some(&config.src), &config.git_config(), &[
@@ -166,7 +166,7 @@ pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String {
166166
config.src.join("src/version"),
167167
])
168168
.unwrap()
169-
} else if let Some(info) = channel::read_commit_info_file(&config.src) {
169+
} else if let Some(info) = crate::utils::channel::read_commit_info_file(&config.src) {
170170
info.sha.trim().to_owned()
171171
} else {
172172
"".to_owned()
@@ -242,15 +242,40 @@ pub(crate) fn is_ci_llvm_available(config: &Config, asserts: bool) -> bool {
242242

243243
/// Returns true if we're running in CI with modified LLVM (and thus can't download it)
244244
pub(crate) fn is_ci_llvm_modified(config: &Config) -> bool {
245-
CiEnv::is_rust_lang_managed_ci_job() && config.rust_info.is_managed_git_subrepository() && {
246-
// We assume we have access to git, so it's okay to unconditionally pass
247-
// `true` here.
248-
let llvm_sha = detect_llvm_sha(config, true);
249-
let head_sha =
250-
output(helpers::git(Some(&config.src)).arg("rev-parse").arg("HEAD").as_command_mut());
251-
let head_sha = head_sha.trim();
252-
llvm_sha == head_sha
245+
// If not running in a CI environment, return false.
246+
if !CiEnv::is_ci() {
247+
return false;
248+
}
249+
250+
// In rust-lang/rust managed CI, assert the existence of the LLVM submodule.
251+
if CiEnv::is_rust_lang_managed_ci_job() {
252+
assert!(
253+
config.in_tree_llvm_info.is_managed_git_subrepository(),
254+
"LLVM submodule must be fetched in rust-lang/rust managed CI builders."
255+
);
253256
}
257+
// If LLVM submodule isn't present, skip the change check as it won't work.
258+
else if !config.in_tree_llvm_info.is_managed_git_subrepository() {
259+
return false;
260+
}
261+
262+
let commit = t!(get_closest_merge_commit(Some(&config.src), &config.git_config(), &[]));
263+
264+
#[allow(clippy::let_and_return)] // makes it look more clear
265+
let is_modified = !t!(helpers::git(Some(&config.src))
266+
.args(["diff-index", "--quiet", &commit])
267+
.arg("--")
268+
.args([
269+
config.src.join("src/llvm-project"),
270+
config.src.join("src/bootstrap/download-ci-llvm-stamp"),
271+
// the LLVM shared object file is named `LLVM-12-rust-{version}-nightly`
272+
config.src.join("src/version"),
273+
])
274+
.as_command_mut()
275+
.status())
276+
.success();
277+
278+
is_modified
254279
}
255280

256281
#[derive(Debug, Clone, Hash, PartialEq, Eq)]

src/bootstrap/src/core/builder/tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ fn alias_and_path_for_library() {
216216

217217
#[test]
218218
fn ci_rustc_if_unchanged_logic() {
219+
if env::var_os("NO_DOWNLOAD_CI_RUSTC").is_some_and(|s| s == "1" || s == "true") {
220+
// FIXME: Find the actual reason.
221+
println!("This test is incompatible in runners configured with `NO_DOWNLOAD_CI_RUSTC`.");
222+
return;
223+
}
224+
219225
let config = Config::parse_inner(
220226
Flags::parse(&[
221227
"build".to_owned(),

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2399,6 +2399,13 @@ impl Config {
23992399
Some(commit) => {
24002400
self.download_ci_rustc(commit);
24012401

2402+
// We never enable `download-rustc` without `download-ci-llvm`. If `self.llvm_from_ci` is false,
2403+
// it means the "if-unchanged" logic has detected some changes in the LLVM submodule.
2404+
if CiEnv::is_ci() && !self.llvm_from_ci {
2405+
println!("WARNING: LLVM submodule has changes, `download-rustc` will be disabled.");
2406+
return None;
2407+
}
2408+
24022409
if let Some(config_path) = &self.config {
24032410
let ci_config_toml = match self.get_builder_toml("ci-rustc") {
24042411
Ok(ci_config_toml) => ci_config_toml,

0 commit comments

Comments
 (0)