Add a description field to target definitions

This is the short description (`64-bit MinGW (Windows 7+)`) including
the platform requirements.

The reason for doing it like this is that this PR will be quite prone to
conflicts whenever targets get added, so it should be as simple as
possible to get it merged. Future PRs which migrate targets are scoped
to groups of targets, so they will not conflict as they can just touch
these.

This moves some of the information from the rustc book into the
compiler.
It cannot be queried yet, that is future work. It is also future work to
fill out all the descriptions, which will coincide with the work of
moving over existing target docs to the new format.
This commit is contained in:
Nilstrieb 2024-03-02 17:12:43 +01:00 committed by Maybe Waffle
parent bdde2a80ae
commit 1db67fb854
229 changed files with 234 additions and 0 deletions

View file

@ -1741,6 +1741,11 @@ impl TargetWarnings {
pub struct Target {
/// Target triple to pass to LLVM.
pub llvm_target: StaticCow<str>,
/// A short description of the target including platform requirements,
/// for example "64-bit Linux (kernel 3.2+, glibc 2.17+)".
/// Optional for now, intended to be required in the future.
/// Part of #120745.
pub description: Option<StaticCow<str>>,
/// Number of bits in a pointer. Influences the `target_pointer_width` `cfg` variable.
pub pointer_width: u32,
/// Architecture to use for ABI considerations. Valid options include: "x86",
@ -2542,6 +2547,7 @@ impl Target {
let mut base = Target {
llvm_target: get_req_field("llvm-target")?.into(),
description: get_req_field("description").ok().map(Into::into),
pointer_width: get_req_field("target-pointer-width")?
.parse::<u32>()
.map_err(|_| "target-pointer-width must be an integer".to_string())?,