Skip to content

Commit

Permalink
Add a description field to target definitions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Nilstrieb authored and WaffleLapkin committed Mar 5, 2024
1 parent bdde2a8 commit 1db67fb
Show file tree
Hide file tree
Showing 229 changed files with 234 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/base/avr_gnu.rs
Expand Up @@ -8,6 +8,7 @@ use object::elf;
pub fn target(target_cpu: &'static str, mmcu: &'static str) -> Target {
Target {
arch: "avr".into(),
description: None,
data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".into(),
llvm_target: "avr-unknown-unknown".into(),
pointer_width: 16,
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Expand Up @@ -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",
Expand Down Expand Up @@ -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())?,
Expand Down
Expand Up @@ -15,6 +15,7 @@ pub fn target() -> Target {
// MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work
// correctly, we do too.
llvm_target: macos_llvm_target(arch).into(),
description: None,
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
Expand Down
Expand Up @@ -12,6 +12,7 @@ pub fn target() -> Target {
// This is required for the target to pick the right
// MACH-O commands, so we do too.
llvm_target: ios_llvm_target(arch).into(),
description: None,
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
Expand Down
Expand Up @@ -8,6 +8,7 @@ pub fn target() -> Target {

Target {
llvm_target: mac_catalyst_llvm_target(arch).into(),
description: None,
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
Expand Down
Expand Up @@ -12,6 +12,7 @@ pub fn target() -> Target {
// This is required for the simulator target to pick the right
// MACH-O commands, so we do too.
llvm_target: ios_sim_llvm_target(arch).into(),
description: None,
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
Expand Down
Expand Up @@ -5,6 +5,7 @@ pub fn target() -> Target {
let arch = Arch::Arm64;
Target {
llvm_target: tvos_llvm_target(arch).into(),
description: None,
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
Expand Down
Expand Up @@ -5,6 +5,7 @@ pub fn target() -> Target {
let arch = Arch::Arm64_sim;
Target {
llvm_target: tvos_sim_llvm_target(arch).into(),
description: None,
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
Expand Down
Expand Up @@ -5,6 +5,7 @@ pub fn target() -> Target {
let base = opts("watchos", Arch::Arm64);
Target {
llvm_target: "aarch64-apple-watchos".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -9,6 +9,7 @@ pub fn target() -> Target {
// This is required for the simulator target to pick the right
// MACH-O commands, so we do too.
llvm_target: watchos_sim_llvm_target(arch).into(),
description: None,
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
Expand Down
Expand Up @@ -4,6 +4,7 @@ use crate::spec::{base, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "aarch64_be-unknown-linux-gnu".into(),
description: None,
pointer_width: 64,
data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -7,6 +7,7 @@ pub fn target() -> Target {

Target {
llvm_target: "aarch64_be-unknown-linux-gnu_ilp32".into(),
description: None,
pointer_width: 32,
data_layout: "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -4,6 +4,7 @@ use crate::spec::{base, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "aarch64_be-unknown-netbsd".into(),
description: None,
pointer_width: 64,
data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -4,6 +4,7 @@ pub fn target() -> Target {
let base = base::solid::opts("asp3");
Target {
llvm_target: "aarch64-unknown-none".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -6,6 +6,7 @@ use crate::spec::{base, SanitizerSet, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "aarch64-linux-android".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -8,6 +8,7 @@ const LINKER_SCRIPT: &str = include_str!("./aarch64_nintendo_switch_freestanding
pub fn target() -> Target {
Target {
llvm_target: "aarch64-unknown-none".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -8,6 +8,7 @@ pub fn target() -> Target {

Target {
llvm_target: "aarch64-pc-windows-gnu".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -7,6 +7,7 @@ pub fn target() -> Target {

Target {
llvm_target: "aarch64-pc-windows-msvc".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{base, SanitizerSet, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "aarch64-unknown-freebsd".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{base, SanitizerSet, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "aarch64-unknown-fuchsia".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{base, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "aarch64-unknown-hermit".into(),
description: None,
pointer_width: 64,
arch: "aarch64".into(),
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
Expand Down
Expand Up @@ -11,6 +11,7 @@ pub fn target() -> Target {
// LLVM does not currently have a separate illumos target,
// so we still pass Solaris to it
llvm_target: "aarch64-unknown-solaris2.11".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{base, SanitizerSet, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "aarch64-unknown-linux-gnu".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{base, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "aarch64-unknown-linux-gnu_ilp32".into(),
description: None,
pointer_width: 32,
data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -14,6 +14,7 @@ pub fn target() -> Target {

Target {
llvm_target: "aarch64-unknown-linux-musl".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -8,6 +8,7 @@ pub fn target() -> Target {
Target {
// LLVM 15 doesn't support OpenHarmony yet, use a linux target instead.
llvm_target: "aarch64-unknown-linux-musl".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{base, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "aarch64-unknown-netbsd".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -31,6 +31,7 @@ pub fn target() -> Target {
};
Target {
llvm_target: "aarch64-unknown-none".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -25,6 +25,7 @@ pub fn target() -> Target {
};
Target {
llvm_target: "aarch64-unknown-none".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{base, Cc, LinkerFlavor, Lld, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "aarch64-unknown-unknown".into(),
description: None,
pointer_width: 64,
// from: https://llvm.org/docs/LangRef.html#data-layout
// e = little endian
Expand Down
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{base, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "aarch64-unknown-openbsd".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -8,6 +8,7 @@ pub fn target() -> Target {

Target {
llvm_target: "aarch64-unknown-redox".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -8,6 +8,7 @@ pub fn target() -> Target {

Target {
llvm_target: "aarch64-unknown-none".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -12,6 +12,7 @@ pub fn target() -> Target {

Target {
llvm_target: "aarch64-unknown-windows".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -7,6 +7,7 @@ pub fn target() -> Target {

Target {
llvm_target: "aarch64-pc-windows-msvc".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{base, StackProbeType, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "aarch64-unknown-linux-gnu".into(),
description: None,
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -5,6 +5,7 @@ pub fn target() -> Target {
let base = opts("watchos", Arch::Arm64_32);
Target {
llvm_target: "arm64_32-apple-watchos".into(),
description: None,
pointer_width: 32,
data_layout: "e-m:o-p:32:32-i64:64-i128:128-n32:64-S128".into(),
arch: "aarch64".into(),
Expand Down
Expand Up @@ -15,6 +15,7 @@ pub fn target() -> Target {
// MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work
// correctly, we do too.
llvm_target: macos_llvm_target(arch).into(),
description: None,
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/targets/arm64e_apple_ios.rs
Expand Up @@ -12,6 +12,7 @@ pub fn target() -> Target {
// This is required for the target to pick the right
// MACH-O commands, so we do too.
llvm_target: ios_llvm_target(arch).into(),
description: None,
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
Expand Down
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{base, SanitizerSet, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "arm-linux-androideabi".into(),
description: None,
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
Expand Down
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{base, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "arm-unknown-linux-gnueabi".into(),
description: None,
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
Expand Down
Expand Up @@ -3,6 +3,7 @@ use crate::spec::{base, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "arm-unknown-linux-gnueabihf".into(),
description: None,
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
Expand Down
Expand Up @@ -6,6 +6,7 @@ pub fn target() -> Target {
// to determine the calling convention and float ABI, and it doesn't
// support the "musleabi" value.
llvm_target: "arm-unknown-linux-gnueabi".into(),
description: None,
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
Expand Down
Expand Up @@ -6,6 +6,7 @@ pub fn target() -> Target {
// uses it to determine the calling convention and float ABI, and it
// doesn't support the "musleabihf" value.
llvm_target: "arm-unknown-linux-gnueabihf".into(),
description: None,
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
Expand Down
Expand Up @@ -4,6 +4,7 @@ use crate::spec::{base, Target, TargetOptions};
pub fn target() -> Target {
Target {
llvm_target: "armeb-unknown-linux-gnueabi".into(),
description: None,
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
Expand Down
Expand Up @@ -6,6 +6,7 @@ use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, Targ
pub fn target() -> Target {
Target {
llvm_target: "armebv7r-none-eabi".into(),
description: None,
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
Expand Down
Expand Up @@ -6,6 +6,7 @@ use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, Targ
pub fn target() -> Target {
Target {
llvm_target: "armebv7r-none-eabihf".into(),
description: None,
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/targets/armv4t_none_eabi.rs
Expand Up @@ -14,6 +14,7 @@ use crate::spec::{cvs, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target,
pub fn target() -> Target {
Target {
llvm_target: "armv4t-none-eabi".into(),
description: None,
pointer_width: 32,
arch: "arm".into(),
/* Data layout args are '-' separated:
Expand Down

0 comments on commit 1db67fb

Please sign in to comment.