Skip to content

Commit

Permalink
Auto merge of rust-lang#124674 - onur-ozkan:followup-124461, r=pietro…
Browse files Browse the repository at this point in the history
…albini

keep the `STAGE0_MISSING_TARGETS` list updated

Implements rust-lang#124461 (comment).

r? pietroalbini
  • Loading branch information
bors committed May 19, 2024
2 parents 496f731 + f2b61d8 commit 7c73595
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! In theory if we get past this phase it's a bug if a build fails, but in
//! practice that's likely not true!

use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use std::env;
use std::ffi::{OsStr, OsString};
use std::fs;
Expand All @@ -33,8 +33,6 @@ pub struct Finder {
// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
const STAGE0_MISSING_TARGETS: &[&str] = &[
// just a dummy comment so the list doesn't get onelined
"aarch64-apple-visionos",
"aarch64-apple-visionos-sim",
];

impl Finder {
Expand Down Expand Up @@ -169,6 +167,12 @@ than building it.
.map(|p| cmd_finder.must_have(p))
.or_else(|| cmd_finder.maybe_have("reuse"));

let stage0_supported_target_list: HashSet<String> =
output(Command::new(&build.config.initial_rustc).args(["--print", "target-list"]))
.lines()
.map(|s| s.to_string())
.collect();

// We're gonna build some custom C code here and there, host triples
// also build some C++ shims for LLVM so we need a C++ compiler.
for target in &build.targets {
Expand All @@ -195,11 +199,19 @@ than building it.
if !["A-A", "B-B", "C-C"].contains(&target_str.as_str()) {
let mut has_target = false;

let supported_target_list =
output(Command::new(&build.config.initial_rustc).args(["--print", "target-list"]));
let missing_targets_hashset: HashSet<_> = STAGE0_MISSING_TARGETS.iter().map(|t| t.to_string()).collect();
let duplicated_targets: Vec<_> = stage0_supported_target_list.intersection(&missing_targets_hashset).collect();

if !duplicated_targets.is_empty() {
println!("Following targets supported from the stage0 compiler, please remove them from STAGE0_MISSING_TARGETS list.");
for duplicated_target in duplicated_targets {
println!(" {duplicated_target}");
}
std::process::exit(1);
}

// Check if it's a built-in target.
has_target |= supported_target_list.contains(&target_str);
has_target |= stage0_supported_target_list.contains(&target_str);
has_target |= STAGE0_MISSING_TARGETS.contains(&target_str.as_str());

if !has_target {
Expand Down

0 comments on commit 7c73595

Please sign in to comment.