Skip to content

Commit 39683d8

Browse files
authored
Merge pull request rust-lang#146 from bjorn3/rustup
Rustup to rustc 1.61.0-nightly (d53246fed 2022-03-25)
2 parents a22e15b + fb9658d commit 39683d8

16 files changed

+98
-68
lines changed

build_sysroot/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version = "0.0.0"
55

66
[dependencies]
77
core = { path = "./sysroot_src/library/core" }
8-
compiler_builtins = "=0.1.70" # TODO: update back to "0.1" when updating to latest nightly.
8+
compiler_builtins = "0.1"
99
alloc = { path = "./sysroot_src/library/alloc" }
1010
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
1111
test = { path = "./sysroot_src/library/test" }

example/mini_core.rs

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ unsafe extern "C" fn _Unwind_Resume() {
1414
#[lang = "sized"]
1515
pub trait Sized {}
1616

17+
#[lang = "destruct"]
18+
pub trait Destruct {}
19+
1720
#[lang = "unsize"]
1821
pub trait Unsize<T: ?Sized> {}
1922

@@ -59,6 +62,7 @@ unsafe impl Copy for i16 {}
5962
unsafe impl Copy for i32 {}
6063
unsafe impl Copy for isize {}
6164
unsafe impl Copy for f32 {}
65+
unsafe impl Copy for f64 {}
6266
unsafe impl Copy for char {}
6367
unsafe impl<'a, T: ?Sized> Copy for &'a T {}
6468
unsafe impl<T: ?Sized> Copy for *const T {}

patches/0024-core-Disable-portable-simd-test.patch

+6-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
1111
index aa1ad93..95fbf55 100644
1212
--- a/library/core/src/lib.rs
1313
+++ b/library/core/src/lib.rs
14-
@@ -398,25 +398,4 @@ pub mod arch {
14+
@@ -398,23 +398,4 @@ pub mod arch {
1515
}
1616
}
1717

@@ -25,12 +25,10 @@ index aa1ad93..95fbf55 100644
2525
-#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)]
2626
-#[allow(rustdoc::bare_urls)]
2727
-#[unstable(feature = "portable_simd", issue = "86656")]
28-
-#[cfg(not(all(miri, doctest)))] // Miri does not support all SIMD intrinsics
2928
-mod core_simd;
3029
-
3130
-#[doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
3231
-#[unstable(feature = "portable_simd", issue = "86656")]
33-
-#[cfg(not(all(miri, doctest)))] // Miri does not support all SIMD intrinsics
3432
-pub mod simd {
3533
- #[unstable(feature = "portable_simd", issue = "86656")]
3634
- pub use crate::core_simd::simd::*;
@@ -41,15 +39,14 @@ diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs
4139
index cd38c3a..ad632dc 100644
4240
--- a/library/core/src/slice/mod.rs
4341
+++ b/library/core/src/slice/mod.rs
44-
@@ -17,7 +17,6 @@ use crate::ptr;
42+
@@ -17,6 +17,5 @@ use crate::ptr;
4543
use crate::result::Result;
4644
use crate::result::Result::{Err, Ok};
47-
#[cfg(not(miri))] // Miri does not support all SIMD intrinsics
4845
-use crate::simd::{self, Simd};
4946
use crate::slice;
5047

5148
#[unstable(
52-
@@ -3475,123 +3474,6 @@ impl<T> [T] {
49+
@@ -3475,121 +3474,6 @@ impl<T> [T] {
5350
}
5451
}
5552

@@ -102,14 +99,13 @@ index cd38c3a..ad632dc 100644
10299
- /// suffix.iter().copied().sum(),
103100
- /// ]);
104101
- /// let sums = middle.iter().copied().fold(sums, f32x4::add);
105-
- /// sums.horizontal_sum()
102+
- /// sums.reduce_sum()
106103
- /// }
107104
- ///
108105
- /// let numbers: Vec<f32> = (1..101).map(|x| x as _).collect();
109106
- /// assert_eq!(basic_simd_sum(&numbers[1..99]), 4949.0);
110107
- /// ```
111108
- #[unstable(feature = "portable_simd", issue = "86656")]
112-
- #[cfg(not(miri))] // Miri does not support all SIMD intrinsics
113109
- pub fn as_simd<const LANES: usize>(&self) -> (&[T], &[Simd<T, LANES>], &[T])
114110
- where
115111
- Simd<T, LANES>: AsRef<[T; LANES]>,
@@ -153,7 +149,6 @@ index cd38c3a..ad632dc 100644
153149
- /// be lifted in a way that would make it possible to see panics from this
154150
- /// method for something like `LANES == 3`.
155151
- #[unstable(feature = "portable_simd", issue = "86656")]
156-
- #[cfg(not(miri))] // Miri does not support all SIMD intrinsics
157152
- pub fn as_simd_mut<const LANES: usize>(&mut self) -> (&mut [T], &mut [Simd<T, LANES>], &mut [T])
158153
- where
159154
- Simd<T, LANES>: AsMut<[T; LANES]>,
@@ -197,15 +192,14 @@ diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
197192
index 5dc586d..b6fc48f 100644
198193
--- a/library/std/src/lib.rs
199194
+++ b/library/std/src/lib.rs
200-
@@ -312,7 +312,6 @@
195+
@@ -312,6 +312,5 @@
201196
#![feature(panic_can_unwind)]
202197
#![feature(panic_unwind)]
203198
#![feature(platform_intrinsics)]
204199
-#![feature(portable_simd)]
205200
#![feature(prelude_import)]
206201
#![feature(ptr_as_uninit)]
207-
#![feature(ptr_internals)]
208-
@@ -508,25 +508,6 @@ pub mod time;
202+
@@ -508,23 +508,6 @@ pub mod time;
209203
#[unstable(feature = "once_cell", issue = "74465")]
210204
pub mod lazy;
211205

@@ -215,10 +209,8 @@ index 5dc586d..b6fc48f 100644
215209
-#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)]
216210
-#[allow(rustdoc::bare_urls)]
217211
-#[unstable(feature = "portable_simd", issue = "86656")]
218-
-#[cfg(not(all(miri, doctest)))] // Miri does not support all SIMD intrinsics
219212
-mod std_float;
220213
-
221-
-#[cfg(not(all(miri, doctest)))] // Miri does not support all SIMD intrinsics
222214
-#[doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
223215
-#[unstable(feature = "portable_simd", issue = "86656")]
224216
-pub mod simd {
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1-
From 0ffdd8eda8df364391c8ac6e1ce92c73ba9254d4 Mon Sep 17 00:00:00 2001
1+
From eb703e627e7a84f1cd8d0d87f0f69da1f0acf765 Mon Sep 17 00:00:00 2001
22
From: bjorn3 <[email protected]>
33
Date: Fri, 3 Dec 2021 12:16:30 +0100
44
Subject: [PATCH] Disable long running tests
55

66
---
7-
library/core/tests/slice.rs | 3 +++
8-
1 file changed, 3 insertions(+)
7+
library/core/tests/slice.rs | 2 ++
8+
1 file changed, 2 insertions(+)
99

1010
diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs
11-
index 2c8f00a..44847ee 100644
11+
index 8402833..84592e0 100644
1212
--- a/library/core/tests/slice.rs
1313
+++ b/library/core/tests/slice.rs
14-
@@ -2332,7 +2332,8 @@ macro_rules! empty_max_mut {
15-
};
16-
}
14+
@@ -2462,6 +2462,7 @@ take_tests! {
15+
#[cfg(not(miri))] // unused in Miri
16+
const EMPTY_MAX: &'static [()] = &[(); usize::MAX];
1717

1818
+/*
19-
#[cfg(not(miri))] // Comparing usize::MAX many elements takes forever in Miri (and in rustc without optimizations)
20-
take_tests! {
21-
slice: &[(); usize::MAX], method: take,
22-
(take_in_bounds_max_range_to, (..usize::MAX), Some(EMPTY_MAX), &[(); 0]),
23-
@@ -2345,3 +2347,4 @@ take_tests! {
19+
// can't be a constant due to const mutability rules
20+
#[cfg(not(miri))] // unused in Miri
21+
macro_rules! empty_max_mut {
22+
@@ -2485,6 +2486,7 @@ take_tests! {
2423
(take_mut_oob_max_range_to_inclusive, (..=usize::MAX), None, empty_max_mut!()),
2524
(take_mut_in_bounds_max_range_from, (usize::MAX..), Some(&mut [] as _), empty_max_mut!()),
2625
}
2726
+*/
27+
28+
#[test]
29+
fn test_slice_from_ptr_range() {
2830
--
2931
2.26.2.7.g19db9cfb68
3032

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2022-02-25"
2+
channel = "nightly-2022-03-26"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

src/allocator.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use gccjit::{FunctionType, ToRValue};
1+
use gccjit::{FunctionType, GlobalKind, ToRValue};
22
use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
33
use rustc_middle::bug;
44
use rustc_middle::ty::TyCtxt;
5+
use rustc_session::config::OomStrategy;
56
use rustc_span::symbol::sym;
67

78
use crate::GccContext;
@@ -113,4 +114,10 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam
113114
let _ret = context.new_call(None, callee, &args);
114115
//llvm::LLVMSetTailCall(ret, True);
115116
block.end_with_void_return(None);
117+
118+
let name = OomStrategy::SYMBOL.to_string();
119+
let global = context.new_global(None, GlobalKind::Exported, i8, name);
120+
let value = tcx.sess.opts.debugging_opts.oom.should_panic();
121+
let value = context.new_rvalue_from_int(i8, value as i32);
122+
global.global_set_initializer_rvalue(value);
116123
}

src/builder.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
934934
let val_type = value.get_type();
935935
match (type_is_pointer(val_type), type_is_pointer(dest_ty)) {
936936
(false, true) => {
937-
// NOTE: Projecting a field of a pointer type will attemp a cast from a signed char to
937+
// NOTE: Projecting a field of a pointer type will attempt a cast from a signed char to
938938
// a pointer, which is not supported by gccjit.
939939
return self.cx.context.new_cast(None, self.inttoptr(value, val_type.make_pointer()), dest_ty);
940940
},
@@ -1251,8 +1251,8 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
12511251
self.cx
12521252
}
12531253

1254-
fn apply_attrs_to_cleanup_callsite(&mut self, _llret: RValue<'gcc>) {
1255-
// TODO
1254+
fn do_not_inline(&mut self, _llret: RValue<'gcc>) {
1255+
// FIMXE(bjorn3): implement
12561256
}
12571257

12581258
fn set_span(&mut self, _span: Span) {}

src/common.rs

+13-20
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_codegen_ssa::traits::{
1111
use rustc_middle::mir::Mutability;
1212
use rustc_middle::ty::ScalarInt;
1313
use rustc_middle::ty::layout::{TyAndLayout, LayoutOf};
14-
use rustc_middle::mir::interpret::{Allocation, GlobalAlloc, Scalar};
14+
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
1515
use rustc_span::Symbol;
1616
use rustc_target::abi::{self, HasDataLayout, Pointer, Size};
1717

@@ -24,18 +24,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
2424
bytes_in_context(self, bytes)
2525
}
2626

27-
fn const_cstr(&self, symbol: Symbol, _null_terminated: bool) -> LValue<'gcc> {
28-
// TODO(antoyo): handle null_terminated.
29-
if let Some(&value) = self.const_cstr_cache.borrow().get(&symbol) {
30-
return value;
31-
}
32-
33-
let global = self.global_string(symbol.as_str());
34-
35-
self.const_cstr_cache.borrow_mut().insert(symbol, global);
36-
global
37-
}
38-
3927
fn global_string(&self, string: &str) -> LValue<'gcc> {
4028
// TODO(antoyo): handle non-null-terminated strings.
4129
let string = self.context.new_string_literal(&*string);
@@ -134,8 +122,12 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
134122
}
135123

136124
fn const_str(&self, s: Symbol) -> (RValue<'gcc>, RValue<'gcc>) {
137-
let len = s.as_str().len();
138-
let cs = self.const_ptrcast(self.const_cstr(s, false).get_address(None),
125+
let s_str = s.as_str();
126+
let str_global = *self.const_str_cache.borrow_mut().entry(s).or_insert_with(|| {
127+
self.global_string(s_str)
128+
});
129+
let len = s_str.len();
130+
let cs = self.const_ptrcast(str_global.get_address(None),
139131
self.type_ptr_to(self.layout_of(self.tcx.types.str_).gcc_type(self, true)),
140132
);
141133
(cs, self.const_usize(len as u64))
@@ -190,6 +182,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
190182
match self.tcx.global_alloc(alloc_id) {
191183
GlobalAlloc::Memory(alloc) => {
192184
let init = const_alloc_to_gcc(self, alloc);
185+
let alloc = alloc.inner();
193186
let value =
194187
match alloc.mutability {
195188
Mutability::Mut => self.static_addr_of_mut(init, alloc.align, None),
@@ -222,21 +215,21 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
222215
}
223216
}
224217

225-
fn const_data_from_alloc(&self, alloc: &Allocation) -> Self::Value {
218+
fn const_data_from_alloc(&self, alloc: ConstAllocation<'tcx>) -> Self::Value {
226219
const_alloc_to_gcc(self, alloc)
227220
}
228221

229-
fn from_const_alloc(&self, layout: TyAndLayout<'tcx>, alloc: &Allocation, offset: Size) -> PlaceRef<'tcx, RValue<'gcc>> {
230-
assert_eq!(alloc.align, layout.align.abi);
222+
fn from_const_alloc(&self, layout: TyAndLayout<'tcx>, alloc: ConstAllocation<'tcx>, offset: Size) -> PlaceRef<'tcx, RValue<'gcc>> {
223+
assert_eq!(alloc.inner().align, layout.align.abi);
231224
let ty = self.type_ptr_to(layout.gcc_type(self, true));
232225
let value =
233226
if layout.size == Size::ZERO {
234-
let value = self.const_usize(alloc.align.bytes());
227+
let value = self.const_usize(alloc.inner().align.bytes());
235228
self.context.new_cast(None, value, ty)
236229
}
237230
else {
238231
let init = const_alloc_to_gcc(self, alloc);
239-
let base_addr = self.static_addr_of(init, alloc.align, None);
232+
let base_addr = self.static_addr_of(init, alloc.inner().align, None);
240233

241234
let array = self.const_bitcast(base_addr, self.type_i8p());
242235
let value = self.context.new_array_access(None, array, self.const_usize(offset.bytes())).get_address(None);

src/consts.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}
77
use rustc_middle::mir::mono::MonoItem;
88
use rustc_middle::ty::{self, Instance, Ty};
99
use rustc_middle::ty::layout::LayoutOf;
10-
use rustc_middle::mir::interpret::{self, Allocation, ErrorHandled, Scalar as InterpScalar, read_target_uint};
10+
use rustc_middle::mir::interpret::{self, ConstAllocation, ErrorHandled, Scalar as InterpScalar, read_target_uint};
1111
use rustc_span::Span;
1212
use rustc_span::def_id::DefId;
1313
use rustc_target::abi::{self, Align, HasDataLayout, Primitive, Size, WrappingRange};
@@ -293,7 +293,8 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
293293
}
294294
}
295295

296-
pub fn const_alloc_to_gcc<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, alloc: &Allocation) -> RValue<'gcc> {
296+
pub fn const_alloc_to_gcc<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, alloc: ConstAllocation<'tcx>) -> RValue<'gcc> {
297+
let alloc = alloc.inner();
297298
let mut llvals = Vec::with_capacity(alloc.relocations().len() + 1);
298299
let dl = cx.data_layout();
299300
let pointer_size = dl.pointer_size.bytes() as usize;
@@ -347,7 +348,7 @@ pub fn const_alloc_to_gcc<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, alloc: &Alloca
347348
cx.const_struct(&llvals, true)
348349
}
349350

350-
pub fn codegen_static_initializer<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, def_id: DefId) -> Result<(RValue<'gcc>, &'tcx Allocation), ErrorHandled> {
351+
pub fn codegen_static_initializer<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, def_id: DefId) -> Result<(RValue<'gcc>, ConstAllocation<'tcx>), ErrorHandled> {
351352
let alloc = cx.tcx.eval_static_initializer(def_id)?;
352353
Ok((const_alloc_to_gcc(cx, alloc), alloc))
353354
}

src/context.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,13 @@ pub struct CodegenCx<'gcc, 'tcx> {
8989

9090
/// Cache of emitted const globals (value -> global)
9191
pub const_globals: RefCell<FxHashMap<RValue<'gcc>, RValue<'gcc>>>,
92+
9293
/// Map from the address of a global variable (rvalue) to the global variable itself (lvalue).
9394
/// TODO(antoyo): remove when the rustc API is fixed.
9495
pub global_lvalues: RefCell<FxHashMap<RValue<'gcc>, LValue<'gcc>>>,
9596

9697
/// Cache of constant strings,
97-
pub const_cstr_cache: RefCell<FxHashMap<Symbol, LValue<'gcc>>>,
98+
pub const_str_cache: RefCell<FxHashMap<Symbol, LValue<'gcc>>>,
9899

99100
/// Cache of globals.
100101
pub globals: RefCell<FxHashMap<String, RValue<'gcc>>>,
@@ -219,7 +220,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
219220
vtables: Default::default(),
220221
const_globals: Default::default(),
221222
global_lvalues: Default::default(),
222-
const_cstr_cache: Default::default(),
223+
const_str_cache: Default::default(),
223224
globals: Default::default(),
224225
scalar_types: Default::default(),
225226
types: Default::default(),

src/debuginfo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
3131
}
3232

3333
impl<'gcc, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
34-
fn create_vtable_metadata(&self, _ty: Ty<'tcx>, _trait_ref: Option<PolyExistentialTraitRef<'tcx>>, _vtable: Self::Value) {
34+
fn create_vtable_debuginfo(&self, _ty: Ty<'tcx>, _trait_ref: Option<PolyExistentialTraitRef<'tcx>>, _vtable: Self::Value) {
3535
// TODO(antoyo)
3636
}
3737

src/intrinsic/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -260,20 +260,20 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
260260
use rustc_target::abi::Abi::*;
261261
let tp_ty = substs.type_at(0);
262262
let layout = self.layout_of(tp_ty).layout;
263-
let _use_integer_compare = match layout.abi {
263+
let _use_integer_compare = match layout.abi() {
264264
Scalar(_) | ScalarPair(_, _) => true,
265265
Uninhabited | Vector { .. } => false,
266266
Aggregate { .. } => {
267267
// For rusty ABIs, small aggregates are actually passed
268268
// as `RegKind::Integer` (see `FnAbi::adjust_for_abi`),
269269
// so we re-use that same threshold here.
270-
layout.size <= self.data_layout().pointer_size * 2
270+
layout.size() <= self.data_layout().pointer_size * 2
271271
}
272272
};
273273

274274
let a = args[0].immediate();
275275
let b = args[1].immediate();
276-
if layout.size.bytes() == 0 {
276+
if layout.size().bytes() == 0 {
277277
self.const_bool(true)
278278
}
279279
/*else if use_integer_compare {
@@ -289,7 +289,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
289289
let void_ptr_type = self.context.new_type::<*const ()>();
290290
let a_ptr = self.bitcast(a, void_ptr_type);
291291
let b_ptr = self.bitcast(b, void_ptr_type);
292-
let n = self.context.new_cast(None, self.const_usize(layout.size.bytes()), self.sizet_type);
292+
let n = self.context.new_cast(None, self.const_usize(layout.size().bytes()), self.sizet_type);
293293
let builtin = self.context.get_builtin_function("memcmp");
294294
let cmp = self.context.new_call(None, builtin, &[a_ptr, b_ptr, n]);
295295
self.icmp(IntPredicate::IntEQ, cmp, self.const_i32(0))

0 commit comments

Comments
 (0)