Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep the STAGE0_MISSING_TARGETS list updated #124674

Merged
merged 1 commit into from
May 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", "B", "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
Loading