Rollup merge of #144443 - WaffleLapkin:integer-target-pointer-width, r=Noratrieb
Make target pointer width in target json an integer r? Noratrieb cc `@RalfJung` (https://github.com/rust-lang/rust/pull/142352/files#r2230380120) try-job: x86_64-rust-for-linux
This commit is contained in:
@@ -315,7 +315,7 @@ pub enum TargetDataLayoutErrors<'a> {
|
||||
MissingAlignment { cause: &'a str },
|
||||
InvalidAlignment { cause: &'a str, err: AlignFromBytesError },
|
||||
InconsistentTargetArchitecture { dl: &'a str, target: &'a str },
|
||||
InconsistentTargetPointerWidth { pointer_size: u64, target: u32 },
|
||||
InconsistentTargetPointerWidth { pointer_size: u64, target: u16 },
|
||||
InvalidBitsSize { err: String },
|
||||
UnknownPointerSpecification { err: String },
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ impl IntTy {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn normalize(&self, target_width: u32) -> Self {
|
||||
pub fn normalize(&self, target_width: u16) -> Self {
|
||||
match self {
|
||||
IntTy::Isize => match target_width {
|
||||
16 => IntTy::I16,
|
||||
@@ -148,7 +148,7 @@ impl UintTy {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn normalize(&self, target_width: u32) -> Self {
|
||||
pub fn normalize(&self, target_width: u16) -> Self {
|
||||
match self {
|
||||
UintTy::Usize => match target_width {
|
||||
16 => UintTy::U16,
|
||||
|
||||
@@ -22,5 +22,5 @@
|
||||
"unix"
|
||||
],
|
||||
"target-mcount": "_mcount",
|
||||
"target-pointer-width": "32"
|
||||
"target-pointer-width": 32
|
||||
}
|
||||
|
||||
@@ -25,10 +25,7 @@ impl Target {
|
||||
let mut base = Target {
|
||||
llvm_target: json.llvm_target,
|
||||
metadata: Default::default(),
|
||||
pointer_width: json
|
||||
.target_pointer_width
|
||||
.parse()
|
||||
.map_err(|err| format!("invalid target-pointer-width: {err}"))?,
|
||||
pointer_width: json.target_pointer_width,
|
||||
data_layout: json.data_layout,
|
||||
arch: json.arch,
|
||||
options: Default::default(),
|
||||
@@ -245,19 +242,17 @@ impl ToJson for Target {
|
||||
target.update_to_cli();
|
||||
|
||||
macro_rules! target_val {
|
||||
($attr:ident) => {{
|
||||
let name = (stringify!($attr)).replace("_", "-");
|
||||
d.insert(name, target.$attr.to_json());
|
||||
($attr:ident) => {
|
||||
target_val!($attr, (stringify!($attr)).replace("_", "-"))
|
||||
};
|
||||
($attr:ident, $json_name:expr) => {{
|
||||
let name = $json_name;
|
||||
d.insert(name.into(), target.$attr.to_json());
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! target_option_val {
|
||||
($attr:ident) => {{
|
||||
let name = (stringify!($attr)).replace("_", "-");
|
||||
if default.$attr != target.$attr {
|
||||
d.insert(name, target.$attr.to_json());
|
||||
}
|
||||
}};
|
||||
($attr:ident) => {{ target_option_val!($attr, (stringify!($attr)).replace("_", "-")) }};
|
||||
($attr:ident, $json_name:expr) => {{
|
||||
let name = $json_name;
|
||||
if default.$attr != target.$attr {
|
||||
@@ -290,7 +285,7 @@ impl ToJson for Target {
|
||||
|
||||
target_val!(llvm_target);
|
||||
target_val!(metadata);
|
||||
d.insert("target-pointer-width".to_string(), self.pointer_width.to_string().to_json());
|
||||
target_val!(pointer_width, "target-pointer-width");
|
||||
target_val!(arch);
|
||||
target_val!(data_layout);
|
||||
|
||||
@@ -463,7 +458,7 @@ struct TargetSpecJsonMetadata {
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct TargetSpecJson {
|
||||
llvm_target: StaticCow<str>,
|
||||
target_pointer_width: String,
|
||||
target_pointer_width: u16,
|
||||
data_layout: StaticCow<str>,
|
||||
arch: StaticCow<str>,
|
||||
|
||||
|
||||
@@ -2331,7 +2331,7 @@ pub struct Target {
|
||||
/// Used for generating target documentation.
|
||||
pub metadata: TargetMetadata,
|
||||
/// Number of bits in a pointer. Influences the `target_pointer_width` `cfg` variable.
|
||||
pub pointer_width: u32,
|
||||
pub pointer_width: u16,
|
||||
/// Architecture to use for ABI considerations. Valid options include: "x86",
|
||||
/// "x86_64", "arm", "aarch64", "mips", "powerpc", "powerpc64", and others.
|
||||
pub arch: StaticCow<str>,
|
||||
|
||||
@@ -7,7 +7,7 @@ fn report_unused_fields() {
|
||||
"arch": "powerpc64",
|
||||
"data-layout": "e-m:e-i64:64-n32:64",
|
||||
"llvm-target": "powerpc64le-elf",
|
||||
"target-pointer-width": "64",
|
||||
"target-pointer-width": 64,
|
||||
"code-mode": "foo"
|
||||
}
|
||||
"#;
|
||||
|
||||
@@ -19,5 +19,5 @@
|
||||
},
|
||||
"panic-strategy": "abort",
|
||||
"relocation-model": "static",
|
||||
"target-pointer-width": "32"
|
||||
"target-pointer-width": 32
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
LINUX_VERSION=v6.16-rc1
|
||||
# https://github.com/rust-lang/rust/pull/144443
|
||||
LINUX_VERSION=7770d51bce622b13195b2d3c85407282fc9c27e5
|
||||
|
||||
# Build rustc, rustdoc, cargo, clippy-driver and rustfmt
|
||||
../x.py build --stage 2 library rustdoc clippy rustfmt
|
||||
|
||||
@@ -6,7 +6,6 @@ use std::sync::OnceLock;
|
||||
use build_helper::git::GitConfig;
|
||||
use camino::{Utf8Path, Utf8PathBuf};
|
||||
use semver::Version;
|
||||
use serde::de::{Deserialize, Deserializer, Error as _};
|
||||
|
||||
use crate::executor::ColorConfig;
|
||||
use crate::fatal;
|
||||
@@ -1072,7 +1071,7 @@ pub struct TargetCfg {
|
||||
pub(crate) abi: String,
|
||||
#[serde(rename = "target-family", default)]
|
||||
pub(crate) families: Vec<String>,
|
||||
#[serde(rename = "target-pointer-width", deserialize_with = "serde_parse_u32")]
|
||||
#[serde(rename = "target-pointer-width")]
|
||||
pub(crate) pointer_width: u32,
|
||||
#[serde(rename = "target-endian", default)]
|
||||
endian: Endian,
|
||||
@@ -1182,11 +1181,6 @@ fn query_rustc_output(config: &Config, args: &[&str], envs: HashMap<String, Stri
|
||||
String::from_utf8(output.stdout).unwrap()
|
||||
}
|
||||
|
||||
fn serde_parse_u32<'de, D: Deserializer<'de>>(deserializer: D) -> Result<u32, D::Error> {
|
||||
let string = String::deserialize(deserializer)?;
|
||||
string.parse().map_err(D::Error::custom)
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TestPaths {
|
||||
pub file: Utf8PathBuf, // e.g., compile-test/foo/bar/baz.rs
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"llvm-target": "x86_64-unknown-none",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "64",
|
||||
"target-pointer-width": 64,
|
||||
"target-c-int-width": 32,
|
||||
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
|
||||
"arch": "x86_64",
|
||||
|
||||
@@ -53,5 +53,5 @@
|
||||
"target-family": [
|
||||
"unix"
|
||||
],
|
||||
"target-pointer-width": "64"
|
||||
"target-pointer-width": 64
|
||||
}
|
||||
|
||||
@@ -33,5 +33,5 @@
|
||||
"thread"
|
||||
],
|
||||
"target-family": "unix",
|
||||
"target-pointer-width": "64"
|
||||
"target-pointer-width": 64
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"linker-flavor": "gcc",
|
||||
"llvm-target": "x86_64-unknown-linux-gnu",
|
||||
"target-endian": "big",
|
||||
"target-pointer-width": "64",
|
||||
"target-pointer-width": 64,
|
||||
"arch": "x86_64",
|
||||
"os": "linux"
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
"arch": "x86_64",
|
||||
"data-layout": "e-m:e-i64:16:32:64",
|
||||
"llvm-target": "x86_64-unknown-unknown-gnu",
|
||||
"target-pointer-width": "64"
|
||||
"target-pointer-width": 64
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"linker-flavor": "gcc",
|
||||
"llvm-target": "i686-unknown-linux-gnu",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "32",
|
||||
"target-pointer-width": 32,
|
||||
"arch": "x86",
|
||||
"os": "linux"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"data-layout": "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32",
|
||||
"linker-flavor": "gcc",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "32",
|
||||
"target-pointer-width": 32,
|
||||
"arch": "x86",
|
||||
"os": "foo"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"linker-flavor": "gcc",
|
||||
"llvm-target": "x86_64-unknown-linux-gnu",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "64",
|
||||
"target-pointer-width": 64,
|
||||
"arch": "x86_64",
|
||||
"os": "linux"
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"linker-flavor": "gcc",
|
||||
"llvm-target": "i686-unknown-linux-gnu",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "32",
|
||||
"target-pointer-width": 32,
|
||||
"arch": "x86",
|
||||
"os": "linux",
|
||||
"need-explicit-cpu": true
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
|
||||
"arch": "x86_64",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "64",
|
||||
"target-pointer-width": 64,
|
||||
"os": "ericos",
|
||||
"linker-flavor": "ld.lld",
|
||||
"linker": "rust-lld",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
|
||||
"arch": "x86_64",
|
||||
"target-endian": "little",
|
||||
"target-pointer-width": "64",
|
||||
"target-pointer-width": 64,
|
||||
"os": "none",
|
||||
"linker-flavor": "ld.lld",
|
||||
"linker": "rust-lld",
|
||||
|
||||
Reference in New Issue
Block a user