Skip to content

Commit d255c6a

Browse files
committedMar 11, 2024·
Auto merge of rust-lang#122305 - Nilstrieb:target-tiers, r=davidtwco
Add metadata to targets follow up to rust-lang#121905 and rust-lang#122157 This adds four pieces of metadata to every target: - description - tier - host tools - std This information is currently scattered across target docs and both - not machine readable, making validation harder - sometimes subtly encoding by the table it's in, causing mistakes and making it harder to review changes to the properties By putting it in the compiler, we improve this. Later, we will use this canonical information to generate target documentation from it. I used find-replace for all the `description: None`. One thing I'm not sure about is the behavior for the JSON. It doesn't really make sense that custom targets supply this information, especially the tier. But for the roundtrip tests, we do need to print and parse it. Maybe emit a warning when a custom target provides the metadata key? Either way, I don't think that's important right now, this PR should get merged ASAP or it will conflict all over the place. r? davidtwco
2 parents e919669 + 5bcb66c commit d255c6a

File tree

232 files changed

+1422
-238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+1422
-238
lines changed
 

‎compiler/rustc_target/src/json.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use std::borrow::Cow;
22
use std::collections::BTreeMap;
33

44
pub use serde_json::Value as Json;
5-
use serde_json::{Map, Number};
5+
use serde_json::{json, Map, Number};
6+
7+
use crate::spec::TargetMetadata;
68

79
pub trait ToJson {
810
fn to_json(&self) -> Json;
@@ -120,3 +122,14 @@ impl ToJson for crate::abi::call::Conv {
120122
Json::String(s.to_owned())
121123
}
122124
}
125+
126+
impl ToJson for TargetMetadata {
127+
fn to_json(&self) -> Json {
128+
json!({
129+
"description": self.description,
130+
"tier": self.tier,
131+
"host_tools": self.host_tools,
132+
"std": self.std,
133+
})
134+
}
135+
}

‎compiler/rustc_target/src/spec/base/avr_gnu.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ use object::elf;
88
pub fn target(target_cpu: &'static str, mmcu: &'static str) -> Target {
99
Target {
1010
arch: "avr".into(),
11-
description: None,
11+
metadata: crate::spec::TargetMetadata {
12+
description: None,
13+
tier: None,
14+
host_tools: None,
15+
std: None,
16+
},
1217
data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".into(),
1318
llvm_target: "avr-unknown-unknown".into(),
1419
pointer_width: 16,

0 commit comments

Comments
 (0)
Please sign in to comment.