Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions tests/cases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,20 @@ Bare WebAssembly and freestanding targets exclude this case in `cases.toml`
because they have no process environment provider. WASI still compiles it;
its runtime selector classifies this native-only case as unsupported rather
than counting it as executed.

## Target identities and CPU profiles

`cases.toml` version 3 separates base architectures in `[supported]` and
`[ci]` from optional processor profiles in `[profiles]`

Rhea uses the `arm64` base ISA; SHAKTI, XiangShan and T-Head use `riscv64`
These Linux profiles remain disabled until their compiler/runtime contracts exist

A base target runs `shared`, `shared/<arch>`, then `<os>/<arch>`
A profile target also inherits `shared/<profile>` and `<os>/<profile>`
after the corresponding base-architecture suite of each kind

A supported profile requires an explicit `[[target]]` entry with matching
`os`, base `arch` and `profile` fields, plus an explicit target runner
Profile identity does not imply new compiler target triples or ISA support
Existing CI-enabled base targets and their matrices are unchanged
19 changes: 14 additions & 5 deletions tests/cases/cases.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 2
version = 3

# List only existing OS ports or publicly documented porting work. Every listed
# cell must appear in both tables; false means planned in Wave, not an invented
Expand All @@ -13,7 +13,7 @@ version = 2
# Fuchsia RISC-V: https://fuchsia.dev/fuchsia-src/contribute/governance/rfcs/0211_fuchsia_on_risc-v
# iOS amd64 is reserved for the simulator, not physical iOS devices (Wave #473).
[supported]
linux = { amd64 = true, arm64 = true, riscv64 = true, loong64 = true, rhea = false, shakti = false, xiangshan = false, t-head = false }
linux = { amd64 = true, arm64 = true, riscv64 = true, loong64 = true }
macos = { amd64 = true, arm64 = true }
windows = { amd64 = true, arm64 = true }
freebsd = { amd64 = true, arm64 = true, riscv64 = true }
Expand All @@ -28,7 +28,7 @@ wasm = { wasm32 = true, wasm64 = true }
wasi = { wasm32 = true, wasm64 = false }

[ci]
linux = { amd64 = true, arm64 = true, riscv64 = true, loong64 = true, rhea = false, shakti = false, xiangshan = false, t-head = false }
linux = { amd64 = true, arm64 = true, riscv64 = true, loong64 = true }
macos = { amd64 = true, arm64 = true }
windows = { amd64 = true, arm64 = true }
freebsd = { amd64 = true, arm64 = true, riscv64 = true }
Expand All @@ -42,9 +42,18 @@ ios = { amd64 = false, arm64 = false }
wasm = { wasm32 = true, wasm64 = true }
wasi = { wasm32 = true, wasm64 = false }

# Processor names are profiles of base ISAs, not architectures or compiler
# targets. They remain disabled until the compiler and runtime support them.
[profiles]
rhea = { os = "linux", arch = "arm64", supported = false, ci = false }
shakti = { os = "linux", arch = "riscv64", supported = false, ci = false }
xiangshan = { os = "linux", arch = "riscv64", supported = false, ci = false }
t-head = { os = "linux", arch = "riscv64", supported = false, ci = false }

# Only supported=true cells need execution details below. Every target gets
# shared, shared/<arch>, and <os>/<arch> suites automatically. Support=false
# cells become disabled planned targets.
# shared, shared/<arch>, and <os>/<arch> suites automatically. Profile targets
# also get shared/<profile> and <os>/<profile> after the base suites.
# Support=false entries remain disabled planned targets.

[[target]]
id = "linux-amd64"
Expand Down
161 changes: 148 additions & 13 deletions tools/src/cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const CAPABILITIES: &[&str] =
pub struct Target {
pub id: String,
pub os: String,
/// Base ISA, independent of the optional processor profile.
pub arch: String,
pub profile: Option<String>,
pub executor: String,
pub runner: Option<String>,
pub group: Option<String>,
Expand All @@ -29,7 +31,15 @@ pub struct Target {

impl Target {
pub fn suites(&self) -> Vec<String> {
vec!["shared".into(), format!("shared/{}", self.arch), format!("{}/{}", self.os, self.arch)]
let mut suites = vec!["shared".into(), format!("shared/{}", self.arch)];
if let Some(profile) = &self.profile {
suites.push(format!("shared/{profile}"));
}
suites.push(format!("{}/{}", self.os, self.arch));
if let Some(profile) = &self.profile {
suites.push(format!("{}/{profile}", self.os));
}
suites
}

pub fn rust_target(&self) -> Result<String> {
Expand Down Expand Up @@ -62,8 +72,16 @@ impl Target {
("id", Value::string(&self.id)),
("os", Value::string(&self.os)),
("arch", Value::string(&self.arch)),
("profile", Value::optional_string(self.profile.as_deref())),
("executor", Value::string(&self.executor)),
("suite", Value::string(format!("{}/{}", self.os, self.arch))),
(
"suite",
Value::string(format!(
"{}/{}",
self.os,
self.profile.as_deref().unwrap_or(&self.arch)
)),
),
("suites", Value::strings(self.suites())),
(
"status",
Expand Down Expand Up @@ -94,6 +112,14 @@ pub struct Manifest {
pub root: PathBuf,
}

#[derive(Debug)]
struct Profile {
os: String,
arch: String,
enabled: bool,
ci: bool,
}

fn name(value: &str) -> bool {
!value.is_empty()
&& value.bytes().enumerate().all(|(i, b)| {
Expand Down Expand Up @@ -162,8 +188,11 @@ fn matrix(value: &toml::Value, key: &str) -> Result<BTreeMap<(String, String), b
.filter(|t| !t.is_empty())
.ok_or_else(|| error("empty architecture row"))?;
for (arch, enabled) in arches {
if !name(arch) {
return Err(error("invalid architecture name"));
if !name(arch)
|| !["amd64", "arm64", "riscv64", "loong64", "wasm32", "wasm64"]
.contains(&arch.as_str())
{
return Err(error("invalid base architecture name"));
}
result.insert(
(os.clone(), arch.clone()),
Expand All @@ -174,6 +203,51 @@ fn matrix(value: &toml::Value, key: &str) -> Result<BTreeMap<(String, String), b
Ok(result)
}

fn profiles(
data: &toml::Value,
supported: &BTreeMap<(String, String), bool>,
) -> Result<BTreeMap<String, Profile>> {
let table = data
.get("profiles")
.and_then(toml::Value::as_table)
.ok_or_else(|| error("missing [profiles] table"))?;
let mut result = BTreeMap::new();
for (profile, fields) in table {
let base_arch = match profile.as_str() {
"rhea" => "arm64",
"shakti" | "xiangshan" | "t-head" => "riscv64",
_ => return Err(error(format!("unknown CPU profile: {profile}"))),
};
let fields =
fields.as_table().ok_or_else(|| error(format!("invalid CPU profile: {profile}")))?;
if fields.keys().any(|key| !matches!(key.as_str(), "os" | "arch" | "supported" | "ci")) {
return Err(error(format!("unknown field in CPU profile: {profile}")));
}
let os = required(fields, "os")?;
let arch = required(fields, "arch")?;
let enabled = fields
.get("supported")
.and_then(toml::Value::as_bool)
.ok_or_else(|| error(format!("missing boolean support for profile: {profile}")))?;
let ci = fields
.get("ci")
.and_then(toml::Value::as_bool)
.ok_or_else(|| error(format!("missing boolean CI for profile: {profile}")))?;
if os != "linux"
|| arch != base_arch
|| !supported.contains_key(&(os.clone(), arch.clone()))
|| enabled && !supported[&(os.clone(), arch.clone())]
|| ci && !enabled
{
return Err(error(format!(
"invalid base architecture or status for profile: {profile}"
)));
}
result.insert(profile.clone(), Profile { os, arch, enabled, ci });
}
Ok(result)
}

impl Manifest {
pub fn load(root: &Path, validate_layout: bool) -> Result<Self> {
Self::parse(
Expand All @@ -186,10 +260,9 @@ impl Manifest {
pub fn parse(text: &str, root: PathBuf, validate_layout: bool) -> Result<Self> {
let data: toml::Value = text.parse()?;
let table = data.as_table().ok_or_else(|| error("manifest must be a table"))?;
if table
.keys()
.any(|key| !matches!(key.as_str(), "version" | "supported" | "ci" | "target"))
|| data.get("version").and_then(toml::Value::as_integer) != Some(2)
if table.keys().any(|key| {
!matches!(key.as_str(), "version" | "supported" | "ci" | "profiles" | "target")
}) || data.get("version").and_then(toml::Value::as_integer) != Some(3)
{
return Err(error("unknown manifest fields or unsupported version"));
}
Expand All @@ -198,6 +271,7 @@ impl Manifest {
if supported.keys().ne(ci.keys()) || supported.iter().any(|(k, v)| ci[k] && !*v) {
return Err(error("support/CI matrices disagree"));
}
let profiles = profiles(&data, &supported)?;
let mut targets = Vec::new();
let mut configured = BTreeSet::new();
let mut ids = BTreeSet::new();
Expand All @@ -212,6 +286,7 @@ impl Manifest {
k.as_str(),
"id" | "os"
| "arch"
| "profile"
| "executor"
| "runner"
| "ci_group"
Expand All @@ -227,11 +302,25 @@ impl Manifest {
let id = required(raw, "id")?;
let os = required(raw, "os")?;
let arch = required(raw, "arch")?;
let profile = optional(raw, "profile")?;
let pair = (os.clone(), arch.clone());
let (enabled, target_ci) = if let Some(profile_name) = &profile {
let defined = profiles
.get(profile_name)
.ok_or_else(|| error(format!("unknown CPU profile: {profile_name}")))?;
if defined.os != os || defined.arch != arch {
return Err(error(format!(
"profile {profile_name} does not match target {id} base architecture"
)));
}
(defined.enabled, defined.ci)
} else {
(supported.get(&pair) == Some(&true), ci.get(&pair).copied().unwrap_or(false))
};
if !name(&id)
|| !ids.insert(id.clone())
|| !configured.insert(pair.clone())
|| supported.get(&pair) != Some(&true)
|| !configured.insert((os.clone(), arch.clone(), profile.clone()))
|| !enabled
{
return Err(error(format!("invalid/duplicate/unsupported target {id}")));
}
Expand All @@ -240,6 +329,7 @@ impl Manifest {
id,
os,
arch,
profile,
executor,
runner: optional(raw, "runner")?,
group: optional(raw, "ci_group")?,
Expand All @@ -249,7 +339,7 @@ impl Manifest {
exclude: strings(raw, "exclude")?,
capabilities: strings(raw, "capabilities")?,
enabled: true,
ci: ci[&pair],
ci: target_ci,
};
if !["native", "compile", "qemu", "wasm"].contains(&target.executor.as_str())
|| target.executor != "native" && target.triple.is_none()
Expand Down Expand Up @@ -297,7 +387,7 @@ impl Manifest {
targets.push(target);
}
for ((os, arch), enabled) in &supported {
if *enabled && !configured.contains(&(os.clone(), arch.clone())) {
if *enabled && !configured.contains(&(os.clone(), arch.clone(), None)) {
return Err(error("supported target has no execution table"));
}
if !enabled {
Expand All @@ -309,6 +399,42 @@ impl Manifest {
id,
os: os.clone(),
arch: arch.clone(),
profile: None,
executor: "none".into(),
runner: None,
group: None,
triple: None,
smoke_case: None,
smoke_stdout: None,
exclude: vec![],
capabilities: vec![],
enabled: false,
ci: false,
});
}
}
for (profile_name, profile) in &profiles {
if profile.enabled
&& !configured.contains(&(
profile.os.clone(),
profile.arch.clone(),
Some(profile_name.clone()),
))
{
return Err(error(format!(
"supported CPU profile has no execution table: {profile_name}"
)));
}
if !profile.enabled {
let id = format!("{}-{profile_name}", profile.os);
if !ids.insert(id.clone()) {
return Err(error("duplicate planned CPU profile ID"));
}
targets.push(Target {
id,
os: profile.os.clone(),
arch: profile.arch.clone(),
profile: Some(profile_name.clone()),
executor: "none".into(),
runner: None,
group: None,
Expand Down Expand Up @@ -343,7 +469,13 @@ impl Manifest {
let matches: Vec<_> = self
.targets
.iter()
.filter(|t| t.enabled && t.executor == "native" && t.os == os && t.arch == arch)
.filter(|t| {
t.enabled
&& t.profile.is_none()
&& t.executor == "native"
&& t.os == os
&& t.arch == arch
})
.collect();
if matches.len() != 1 {
return Err(error("expected one native target for this host"));
Expand Down Expand Up @@ -546,6 +678,9 @@ impl Manifest {
("shard_index", Value::integer(index)),
("shard_count", Value::integer(2)),
]);
if let Some(profile) = &target.profile {
config::field(&mut value, "profile", Value::string(profile))?;
}
for (key, item) in [
("target", &target.triple),
("smoke_case", &target.smoke_case),
Expand Down
Loading
Loading