Skip to content

Commit 4c64d49

Browse files
authored
Rollup merge of rust-lang#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
2 parents e7ec60a + f0e9fd6 commit 4c64d49

File tree

20 files changed

+31
-41
lines changed

20 files changed

+31
-41
lines changed

compiler/rustc_abi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ pub enum TargetDataLayoutErrors<'a> {
315315
MissingAlignment { cause: &'a str },
316316
InvalidAlignment { cause: &'a str, err: AlignFromBytesError },
317317
InconsistentTargetArchitecture { dl: &'a str, target: &'a str },
318-
InconsistentTargetPointerWidth { pointer_size: u64, target: u32 },
318+
InconsistentTargetPointerWidth { pointer_size: u64, target: u16 },
319319
InvalidBitsSize { err: String },
320320
UnknownPointerSpecification { err: String },
321321
}

compiler/rustc_ast_ir/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl IntTy {
6969
})
7070
}
7171

72-
pub fn normalize(&self, target_width: u32) -> Self {
72+
pub fn normalize(&self, target_width: u16) -> Self {
7373
match self {
7474
IntTy::Isize => match target_width {
7575
16 => IntTy::I16,
@@ -148,7 +148,7 @@ impl UintTy {
148148
})
149149
}
150150

151-
pub fn normalize(&self, target_width: u32) -> Self {
151+
pub fn normalize(&self, target_width: u16) -> Self {
152152
match self {
153153
UintTy::Usize => match target_width {
154154
16 => UintTy::U16,

compiler/rustc_codegen_gcc/target_specs/m68k-unknown-linux-gnu.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
"unix"
2323
],
2424
"target-mcount": "_mcount",
25-
"target-pointer-width": "32"
25+
"target-pointer-width": 32
2626
}

compiler/rustc_target/src/spec/json.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ impl Target {
2525
let mut base = Target {
2626
llvm_target: json.llvm_target,
2727
metadata: Default::default(),
28-
pointer_width: json
29-
.target_pointer_width
30-
.parse()
31-
.map_err(|err| format!("invalid target-pointer-width: {err}"))?,
28+
pointer_width: json.target_pointer_width,
3229
data_layout: json.data_layout,
3330
arch: json.arch,
3431
options: Default::default(),
@@ -245,19 +242,17 @@ impl ToJson for Target {
245242
target.update_to_cli();
246243

247244
macro_rules! target_val {
248-
($attr:ident) => {{
249-
let name = (stringify!($attr)).replace("_", "-");
250-
d.insert(name, target.$attr.to_json());
245+
($attr:ident) => {
246+
target_val!($attr, (stringify!($attr)).replace("_", "-"))
247+
};
248+
($attr:ident, $json_name:expr) => {{
249+
let name = $json_name;
250+
d.insert(name.into(), target.$attr.to_json());
251251
}};
252252
}
253253

254254
macro_rules! target_option_val {
255-
($attr:ident) => {{
256-
let name = (stringify!($attr)).replace("_", "-");
257-
if default.$attr != target.$attr {
258-
d.insert(name, target.$attr.to_json());
259-
}
260-
}};
255+
($attr:ident) => {{ target_option_val!($attr, (stringify!($attr)).replace("_", "-")) }};
261256
($attr:ident, $json_name:expr) => {{
262257
let name = $json_name;
263258
if default.$attr != target.$attr {
@@ -290,7 +285,7 @@ impl ToJson for Target {
290285

291286
target_val!(llvm_target);
292287
target_val!(metadata);
293-
d.insert("target-pointer-width".to_string(), self.pointer_width.to_string().to_json());
288+
target_val!(pointer_width, "target-pointer-width");
294289
target_val!(arch);
295290
target_val!(data_layout);
296291

@@ -463,7 +458,7 @@ struct TargetSpecJsonMetadata {
463458
#[serde(deny_unknown_fields)]
464459
struct TargetSpecJson {
465460
llvm_target: StaticCow<str>,
466-
target_pointer_width: String,
461+
target_pointer_width: u16,
467462
data_layout: StaticCow<str>,
468463
arch: StaticCow<str>,
469464

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2324,7 +2324,7 @@ pub struct Target {
23242324
/// Used for generating target documentation.
23252325
pub metadata: TargetMetadata,
23262326
/// Number of bits in a pointer. Influences the `target_pointer_width` `cfg` variable.
2327-
pub pointer_width: u32,
2327+
pub pointer_width: u16,
23282328
/// Architecture to use for ABI considerations. Valid options include: "x86",
23292329
/// "x86_64", "arm", "aarch64", "mips", "powerpc", "powerpc64", and others.
23302330
pub arch: StaticCow<str>,

compiler/rustc_target/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn report_unused_fields() {
77
"arch": "powerpc64",
88
"data-layout": "e-m:e-i64:64-n32:64",
99
"llvm-target": "powerpc64le-elf",
10-
"target-pointer-width": "64",
10+
"target-pointer-width": 64,
1111
"code-mode": "foo"
1212
}
1313
"#;

library/compiler-builtins/etc/thumbv7em-none-eabi-renamed.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
},
2020
"panic-strategy": "abort",
2121
"relocation-model": "static",
22-
"target-pointer-width": "32"
22+
"target-pointer-width": 32
2323
}

src/ci/docker/scripts/rfl-build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
set -euo pipefail
44

5-
LINUX_VERSION=v6.16-rc1
5+
# https://github.com/rust-lang/rust/pull/144443
6+
LINUX_VERSION=7770d51bce622b13195b2d3c85407282fc9c27e5
67

78
# Build rustc, rustdoc, cargo, clippy-driver and rustfmt
89
../x.py build --stage 2 library rustdoc clippy rustfmt

src/tools/compiletest/src/common.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::sync::OnceLock;
66
use build_helper::git::GitConfig;
77
use camino::{Utf8Path, Utf8PathBuf};
88
use semver::Version;
9-
use serde::de::{Deserialize, Deserializer, Error as _};
109

1110
use crate::executor::{ColorConfig, OutputFormat};
1211
use crate::fatal;
@@ -1080,7 +1079,7 @@ pub struct TargetCfg {
10801079
pub(crate) abi: String,
10811080
#[serde(rename = "target-family", default)]
10821081
pub(crate) families: Vec<String>,
1083-
#[serde(rename = "target-pointer-width", deserialize_with = "serde_parse_u32")]
1082+
#[serde(rename = "target-pointer-width")]
10841083
pub(crate) pointer_width: u32,
10851084
#[serde(rename = "target-endian", default)]
10861085
endian: Endian,
@@ -1190,11 +1189,6 @@ fn query_rustc_output(config: &Config, args: &[&str], envs: HashMap<String, Stri
11901189
String::from_utf8(output.stdout).unwrap()
11911190
}
11921191

1193-
fn serde_parse_u32<'de, D: Deserializer<'de>>(deserializer: D) -> Result<u32, D::Error> {
1194-
let string = String::deserialize(deserializer)?;
1195-
string.parse().map_err(D::Error::custom)
1196-
}
1197-
11981192
#[derive(Debug, Clone)]
11991193
pub struct TestPaths {
12001194
pub file: Utf8PathBuf, // e.g., compile-test/foo/bar/baz.rs

src/tools/miri/tests/x86_64-unknown-kernel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"llvm-target": "x86_64-unknown-none",
33
"target-endian": "little",
4-
"target-pointer-width": "64",
4+
"target-pointer-width": 64,
55
"target-c-int-width": 32,
66
"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",
77
"arch": "x86_64",

0 commit comments

Comments
 (0)