Repository navigation
Expand file tree
/
Copy pathrustc-1.74.0-src.patch
More file actions
255 lines (235 loc) · 10.9 KB
/
Copy pathrustc-1.74.0-src.patch
File metadata and controls
255 lines (235 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# mrustc doesn't have as good non-zero niche optimisation
--- compiler/rustc_parse_format/src/lib.rs
+++ compiler/rustc_parse_format/src/lib.rs
@@ -1052,3 +1052,3 @@
// Assert a reasonable size for `Piece`
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
rustc_index::static_assert_size!(Piece<'_>, 16);
--- compiler/rustc_ast/src/ast.rs
+++ compiler/rustc_ast/src/ast.rs
@@ -3167,4 +3167,4 @@
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
mod size_asserts {
use super::*;
--- compiler/rustc_hir/src/hir.rs
+++ compiler/rustc_hir/src/hir.rs
@@ -4078,4 +4078,4 @@
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
mod size_asserts {
use super::*;
--- compiler/rustc_errors/src/lib.rs
+++ compiler/rustc_errors/src/lib.rs
@@ -87,7 +87,7 @@
// (See also the comment on `DiagnosticBuilderInner`'s `diagnostic` field.)
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
rustc_data_structures::static_assert_size!(PResult<'_, ()>, 16);
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
rustc_data_structures::static_assert_size!(PResult<'_, bool>, 16);
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Encodable, Decodable)]
--- compiler/rustc_const_eval/src/interpret/operand.rs
+++ compiler/rustc_const_eval/src/interpret/operand.rs
@@ -755,5 +755,5 @@
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
mod size_asserts {
use super::*;
--- compiler/rustc_const_eval/src/interpret/place.rs
+++ compiler/rustc_const_eval/src/interpret/place.rs
@@ -1091,5 +1091,5 @@
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
mod size_asserts {
use super::*;
--- compiler/rustc_index/src/bit_set.rs
+++ compiler/rustc_index/src/bit_set.rs
@@ -411,3 +411,3 @@
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
crate::static_assert_size!(Chunk, 16);
#
# HACK! Avoid an unsoundness in `Path` by making `Wtf8Buf` start with `Vec<u8>`
#
--- library/std/src/sys_common/wtf8.rs
+++ library/std/src/sys_common/wtf8.rs
@@ -135,3 +135,4 @@
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone)]
+#[cfg_attr(rust_compiler = "mrustc", repr(C))]
pub struct Wtf8Buf {
bytes: Vec<u8>,
#
# Size checks without updated sorting
#
--- compiler/rustc_ast/src/tokenstream.rs
+++ compiler/rustc_ast/src/tokenstream.rs
@@ -739,3 +739,3 @@
// Some types are used a lot. Make sure they don't unintentionally get bigger.
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
mod size_asserts {
--- compiler/rustc_middle/src/mir/consts.rs
+++ compiler/rustc_middle/src/mir/consts.rs
@@ -72,3 +72,3 @@
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
static_assert_size!(ConstValue<'_>, 24);
--- compiler/rustc_middle/src/mir/interpret/value.rs
+++ compiler/rustc_middle/src/mir/interpret/value.rs
@@ -36,3 +36,3 @@
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
static_assert_size!(Scalar, 24);
--- compiler/rustc_middle/src/mir/syntax.rs
+++ compiler/rustc_middle/src/mir/syntax.rs
@@ -1423,3 +1423,3 @@
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
mod size_asserts {
--- compiler/rustc_middle/src/mir/mod.rs
+++ compiler/rustc_middle/src/mir/mod.rs
@@ -1617,3 +1617,3 @@
// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
mod size_asserts {
--- compiler/rustc_middle/src/ty/consts/kind.rs
+++ compiler/rustc_middle/src/ty/consts/kind.rs
@@ -74,3 +74,3 @@
-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
+#[cfg(all(target_arch = "x86_64", target_pointer_width = "64", not(rust_compiler = "mrustc")))]
static_assert_size!(Expr<'_>, 24);
# MSVC Cannot handle structs larger than 32-bit, so disable this for windows with mrustc
--- vendor/hex/src/lib.rs
+++ vendor/hex/src/lib.rs
@@ -238,3 +238,3 @@
-#[cfg(target_pointer_width = "64")]
+#[cfg(all(target_pointer_width = "64", not(rust_compiler = "mrustc")))]
from_hex_array_impl! {
--- src/llvm-project/llvm/include/llvm/ADT/SmallVector.h
+++ src/llvm-project/llvm/include/llvm/ADT/SmallVector.h
@@ -21,2 +21,3 @@
#include <cstddef>
+#include <cstdint>
#include <cstdlib>
--- src/llvm-project/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
+++ src/llvm-project/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
@@ -14,4 +14,5 @@
#define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
+#include <cstdint>
#include <memory>
#include <string>
--- src/llvm-project/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h
+++ src/llvm-project/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h
@@ -16,4 +16,5 @@
#define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUMCTARGETDESC_H
+#include <cstdint>
#include <memory>
# macos_weak only defines the fdopendir weak symbol for x86/x86_64; other macOS targets emit neither arm.
# 10.4/10.5 have no $INODE64 variants, so the plain symbol is the correct one there.
--- library/std/src/sys/unix/fs.rs
+++ library/std/src/sys/unix/fs.rs
@@ -1979,6 +1979,8 @@
weak!(fn fdopendir(c_int) -> *mut DIR, "fdopendir$INODE64$UNIX2003");
#[cfg(all(target_os = "macos", target_arch = "x86_64"))]
weak!(fn fdopendir(c_int) -> *mut DIR, "fdopendir$INODE64");
+ #[cfg(all(target_os = "macos", not(any(target_arch = "x86", target_arch = "x86_64"))))]
+ weak!(fn fdopendir(c_int) -> *mut DIR);
fdopendir.get().map(|fdopendir| fdopendir(fd)).unwrap_or_else(|| {
crate::sys::unix::os::set_errno(libc::ENOSYS);
crate::ptr::null_mut()
# The Darwin thread parker needs libdispatch (10.6+); deployment targets older than that
# opt out via `--cfg no_libdispatch` (set in the powerpc build_std script override).
--- library/std/src/sys/unix/thread_parking/mod.rs
+++ library/std/src/sys/unix/thread_parking/mod.rs
@@ -18,6 +18,10 @@
target_os = "watchos",
target_os = "tvos",
),
+ // The Darwin parker is built on libdispatch, which is 10.6+. Deployment targets
+ // older than that set `--cfg no_libdispatch` (see the build_std script override
+ // for powerpc, which targets 10.4/10.5) to get the generic pthread parker.
+ not(no_libdispatch),
not(miri),
))] {
mod darwin;
# The mach_timebase_info cache was a single AtomicU64 - the only AtomicU64 use in
# libstd without a target_has_atomic fallback. Split it into two AtomicU32s
# (denom==0 is the uninitialized sentinel; numer is published by the Release store
# of denom) so libstd builds on targets without 64-bit atomics (32-bit PowerPC).
--- library/std/src/sys/unix/time.rs
+++ library/std/src/sys/unix/time.rs
@@ -223,7 +223,7 @@
target_os = "tvos"
))]
mod inner {
- use crate::sync::atomic::{AtomicU64, Ordering};
+ use crate::sync::atomic::{AtomicU32, Ordering};
use crate::sys::cvt;
use crate::sys_common::mul_div_u64;
use crate::time::Duration;
@@ -298,19 +298,21 @@
}
fn info() -> mach_timebase_info {
- // INFO_BITS conceptually is an `Option<mach_timebase_info>`. We can do
- // this in 64 bits because we know 0 is never a valid value for the
- // `denom` field.
+ // The numer/denom pair is cached in two `AtomicU32`s: `denom == 0`
+ // marks an uninitialized value - we know 0 is never a valid `denom`.
//
- // Encoding this as a single `AtomicU64` allows us to use `Relaxed`
- // operations, as we are only interested in the effects on a single
- // memory location.
- static INFO_BITS: AtomicU64 = AtomicU64::new(0);
-
- // If a previous thread has initialized `INFO_BITS`, use it.
- let info_bits = INFO_BITS.load(Ordering::Relaxed);
- if info_bits != 0 {
- return info_from_bits(info_bits);
+ // The `numer` store happens-before the `denom` Release store, so a
+ // thread that Acquire-loads a non-zero `denom` also observes the
+ // matching `numer`; racing initializers all write the same values.
+ // (Two 32-bit atomics rather than one `AtomicU64`, so that this also
+ // works on targets without 64-bit atomics, e.g. 32-bit PowerPC.)
+ static INFO_NUMER: AtomicU32 = AtomicU32::new(0);
+ static INFO_DENOM: AtomicU32 = AtomicU32::new(0);
+
+ // If a previous thread has initialized these, use them.
+ let denom = INFO_DENOM.load(Ordering::Acquire);
+ if denom != 0 {
+ return mach_timebase_info { numer: INFO_NUMER.load(Ordering::Relaxed), denom };
}
// ... otherwise learn for ourselves ...
@@ -318,23 +320,14 @@
fn mach_timebase_info(info: mach_timebase_info_t) -> kern_return_t;
}
- let mut info = info_from_bits(0);
+ let mut info = mach_timebase_info { numer: 0, denom: 0 };
unsafe {
mach_timebase_info(&mut info);
}
- INFO_BITS.store(info_to_bits(info), Ordering::Relaxed);
+ INFO_NUMER.store(info.numer, Ordering::Relaxed);
+ INFO_DENOM.store(info.denom, Ordering::Release);
info
}
-
- #[inline]
- fn info_to_bits(info: mach_timebase_info) -> u64 {
- ((info.denom as u64) << 32) | (info.numer as u64)
- }
-
- #[inline]
- fn info_from_bits(bits: u64) -> mach_timebase_info {
- mach_timebase_info { numer: bits as u32, denom: (bits >> 32) as u32 }
- }
}
#[cfg(not(any(