Skip to content

Rustup to rustc 1.61.0-nightly (d53246fed 2022-03-25) #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build_sysroot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.0.0"

[dependencies]
core = { path = "./sysroot_src/library/core" }
compiler_builtins = "=0.1.70" # TODO: update back to "0.1" when updating to latest nightly.
compiler_builtins = "0.1"
alloc = { path = "./sysroot_src/library/alloc" }
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
test = { path = "./sysroot_src/library/test" }
Expand Down
4 changes: 4 additions & 0 deletions example/mini_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ unsafe extern "C" fn _Unwind_Resume() {
#[lang = "sized"]
pub trait Sized {}

#[lang = "destruct"]
pub trait Destruct {}

#[lang = "unsize"]
pub trait Unsize<T: ?Sized> {}

Expand Down Expand Up @@ -59,6 +62,7 @@ unsafe impl Copy for i16 {}
unsafe impl Copy for i32 {}
unsafe impl Copy for isize {}
unsafe impl Copy for f32 {}
unsafe impl Copy for f64 {}
unsafe impl Copy for char {}
unsafe impl<'a, T: ?Sized> Copy for &'a T {}
unsafe impl<T: ?Sized> Copy for *const T {}
Expand Down
20 changes: 6 additions & 14 deletions patches/0024-core-Disable-portable-simd-test.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index aa1ad93..95fbf55 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -398,25 +398,4 @@ pub mod arch {
@@ -398,23 +398,4 @@ pub mod arch {
}
}

Expand All @@ -25,12 +25,10 @@ index aa1ad93..95fbf55 100644
-#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)]
-#[allow(rustdoc::bare_urls)]
-#[unstable(feature = "portable_simd", issue = "86656")]
-#[cfg(not(all(miri, doctest)))] // Miri does not support all SIMD intrinsics
-mod core_simd;
-
-#[doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
-#[unstable(feature = "portable_simd", issue = "86656")]
-#[cfg(not(all(miri, doctest)))] // Miri does not support all SIMD intrinsics
-pub mod simd {
- #[unstable(feature = "portable_simd", issue = "86656")]
- pub use crate::core_simd::simd::*;
Expand All @@ -41,15 +39,14 @@ diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs
index cd38c3a..ad632dc 100644
--- a/library/core/src/slice/mod.rs
+++ b/library/core/src/slice/mod.rs
@@ -17,7 +17,6 @@ use crate::ptr;
@@ -17,6 +17,5 @@ use crate::ptr;
use crate::result::Result;
use crate::result::Result::{Err, Ok};
#[cfg(not(miri))] // Miri does not support all SIMD intrinsics
-use crate::simd::{self, Simd};
use crate::slice;

#[unstable(
@@ -3475,123 +3474,6 @@ impl<T> [T] {
@@ -3475,121 +3474,6 @@ impl<T> [T] {
}
}

Expand Down Expand Up @@ -102,14 +99,13 @@ index cd38c3a..ad632dc 100644
- /// suffix.iter().copied().sum(),
- /// ]);
- /// let sums = middle.iter().copied().fold(sums, f32x4::add);
- /// sums.horizontal_sum()
- /// sums.reduce_sum()
- /// }
- ///
- /// let numbers: Vec<f32> = (1..101).map(|x| x as _).collect();
- /// assert_eq!(basic_simd_sum(&numbers[1..99]), 4949.0);
- /// ```
- #[unstable(feature = "portable_simd", issue = "86656")]
- #[cfg(not(miri))] // Miri does not support all SIMD intrinsics
- pub fn as_simd<const LANES: usize>(&self) -> (&[T], &[Simd<T, LANES>], &[T])
- where
- Simd<T, LANES>: AsRef<[T; LANES]>,
Expand Down Expand Up @@ -153,7 +149,6 @@ index cd38c3a..ad632dc 100644
- /// be lifted in a way that would make it possible to see panics from this
- /// method for something like `LANES == 3`.
- #[unstable(feature = "portable_simd", issue = "86656")]
- #[cfg(not(miri))] // Miri does not support all SIMD intrinsics
- pub fn as_simd_mut<const LANES: usize>(&mut self) -> (&mut [T], &mut [Simd<T, LANES>], &mut [T])
- where
- Simd<T, LANES>: AsMut<[T; LANES]>,
Expand Down Expand Up @@ -197,15 +192,14 @@ diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index 5dc586d..b6fc48f 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -312,7 +312,6 @@
@@ -312,6 +312,5 @@
#![feature(panic_can_unwind)]
#![feature(panic_unwind)]
#![feature(platform_intrinsics)]
-#![feature(portable_simd)]
#![feature(prelude_import)]
#![feature(ptr_as_uninit)]
#![feature(ptr_internals)]
@@ -508,25 +508,6 @@ pub mod time;
@@ -508,23 +508,6 @@ pub mod time;
#[unstable(feature = "once_cell", issue = "74465")]
pub mod lazy;

Expand All @@ -215,10 +209,8 @@ index 5dc586d..b6fc48f 100644
-#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)]
-#[allow(rustdoc::bare_urls)]
-#[unstable(feature = "portable_simd", issue = "86656")]
-#[cfg(not(all(miri, doctest)))] // Miri does not support all SIMD intrinsics
-mod std_float;
-
-#[cfg(not(all(miri, doctest)))] // Miri does not support all SIMD intrinsics
-#[doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
-#[unstable(feature = "portable_simd", issue = "86656")]
-pub mod simd {
Expand Down
26 changes: 14 additions & 12 deletions patches/0028-core-Disable-long-running-tests.patch
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
From 0ffdd8eda8df364391c8ac6e1ce92c73ba9254d4 Mon Sep 17 00:00:00 2001
From eb703e627e7a84f1cd8d0d87f0f69da1f0acf765 Mon Sep 17 00:00:00 2001
From: bjorn3 <[email protected]>
Date: Fri, 3 Dec 2021 12:16:30 +0100
Subject: [PATCH] Disable long running tests

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

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

+/*
#[cfg(not(miri))] // Comparing usize::MAX many elements takes forever in Miri (and in rustc without optimizations)
take_tests! {
slice: &[(); usize::MAX], method: take,
(take_in_bounds_max_range_to, (..usize::MAX), Some(EMPTY_MAX), &[(); 0]),
@@ -2345,3 +2347,4 @@ take_tests! {
// can't be a constant due to const mutability rules
#[cfg(not(miri))] // unused in Miri
macro_rules! empty_max_mut {
@@ -2485,6 +2486,7 @@ take_tests! {
(take_mut_oob_max_range_to_inclusive, (..=usize::MAX), None, empty_max_mut!()),
(take_mut_in_bounds_max_range_from, (usize::MAX..), Some(&mut [] as _), empty_max_mut!()),
}
+*/

#[test]
fn test_slice_from_ptr_range() {
--
2.26.2.7.g19db9cfb68

2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2022-02-25"
channel = "nightly-2022-03-26"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
9 changes: 8 additions & 1 deletion src/allocator.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use gccjit::{FunctionType, ToRValue};
use gccjit::{FunctionType, GlobalKind, ToRValue};
use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
use rustc_middle::bug;
use rustc_middle::ty::TyCtxt;
use rustc_session::config::OomStrategy;
use rustc_span::symbol::sym;

use crate::GccContext;
Expand Down Expand Up @@ -113,4 +114,10 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam
let _ret = context.new_call(None, callee, &args);
//llvm::LLVMSetTailCall(ret, True);
block.end_with_void_return(None);

let name = OomStrategy::SYMBOL.to_string();
let global = context.new_global(None, GlobalKind::Exported, i8, name);
let value = tcx.sess.opts.debugging_opts.oom.should_panic();
let value = context.new_rvalue_from_int(i8, value as i32);
global.global_set_initializer_rvalue(value);
}
6 changes: 3 additions & 3 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
let val_type = value.get_type();
match (type_is_pointer(val_type), type_is_pointer(dest_ty)) {
(false, true) => {
// NOTE: Projecting a field of a pointer type will attemp a cast from a signed char to
// NOTE: Projecting a field of a pointer type will attempt a cast from a signed char to
// a pointer, which is not supported by gccjit.
return self.cx.context.new_cast(None, self.inttoptr(value, val_type.make_pointer()), dest_ty);
},
Expand Down Expand Up @@ -1251,8 +1251,8 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
self.cx
}

fn apply_attrs_to_cleanup_callsite(&mut self, _llret: RValue<'gcc>) {
// TODO
fn do_not_inline(&mut self, _llret: RValue<'gcc>) {
// FIMXE(bjorn3): implement
}

fn set_span(&mut self, _span: Span) {}
Expand Down
33 changes: 13 additions & 20 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_codegen_ssa::traits::{
use rustc_middle::mir::Mutability;
use rustc_middle::ty::ScalarInt;
use rustc_middle::ty::layout::{TyAndLayout, LayoutOf};
use rustc_middle::mir::interpret::{Allocation, GlobalAlloc, Scalar};
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
use rustc_span::Symbol;
use rustc_target::abi::{self, HasDataLayout, Pointer, Size};

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

fn const_cstr(&self, symbol: Symbol, _null_terminated: bool) -> LValue<'gcc> {
// TODO(antoyo): handle null_terminated.
if let Some(&value) = self.const_cstr_cache.borrow().get(&symbol) {
return value;
}

let global = self.global_string(symbol.as_str());

self.const_cstr_cache.borrow_mut().insert(symbol, global);
global
}

fn global_string(&self, string: &str) -> LValue<'gcc> {
// TODO(antoyo): handle non-null-terminated strings.
let string = self.context.new_string_literal(&*string);
Expand Down Expand Up @@ -134,8 +122,12 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
}

fn const_str(&self, s: Symbol) -> (RValue<'gcc>, RValue<'gcc>) {
let len = s.as_str().len();
let cs = self.const_ptrcast(self.const_cstr(s, false).get_address(None),
let s_str = s.as_str();
let str_global = *self.const_str_cache.borrow_mut().entry(s).or_insert_with(|| {
self.global_string(s_str)
});
let len = s_str.len();
let cs = self.const_ptrcast(str_global.get_address(None),
self.type_ptr_to(self.layout_of(self.tcx.types.str_).gcc_type(self, true)),
);
(cs, self.const_usize(len as u64))
Expand Down Expand Up @@ -190,6 +182,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
match self.tcx.global_alloc(alloc_id) {
GlobalAlloc::Memory(alloc) => {
let init = const_alloc_to_gcc(self, alloc);
let alloc = alloc.inner();
let value =
match alloc.mutability {
Mutability::Mut => self.static_addr_of_mut(init, alloc.align, None),
Expand Down Expand Up @@ -222,21 +215,21 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
}
}

fn const_data_from_alloc(&self, alloc: &Allocation) -> Self::Value {
fn const_data_from_alloc(&self, alloc: ConstAllocation<'tcx>) -> Self::Value {
const_alloc_to_gcc(self, alloc)
}

fn from_const_alloc(&self, layout: TyAndLayout<'tcx>, alloc: &Allocation, offset: Size) -> PlaceRef<'tcx, RValue<'gcc>> {
assert_eq!(alloc.align, layout.align.abi);
fn from_const_alloc(&self, layout: TyAndLayout<'tcx>, alloc: ConstAllocation<'tcx>, offset: Size) -> PlaceRef<'tcx, RValue<'gcc>> {
assert_eq!(alloc.inner().align, layout.align.abi);
let ty = self.type_ptr_to(layout.gcc_type(self, true));
let value =
if layout.size == Size::ZERO {
let value = self.const_usize(alloc.align.bytes());
let value = self.const_usize(alloc.inner().align.bytes());
self.context.new_cast(None, value, ty)
}
else {
let init = const_alloc_to_gcc(self, alloc);
let base_addr = self.static_addr_of(init, alloc.align, None);
let base_addr = self.static_addr_of(init, alloc.inner().align, None);

let array = self.const_bitcast(base_addr, self.type_i8p());
let value = self.context.new_array_access(None, array, self.const_usize(offset.bytes())).get_address(None);
Expand Down
7 changes: 4 additions & 3 deletions src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}
use rustc_middle::mir::mono::MonoItem;
use rustc_middle::ty::{self, Instance, Ty};
use rustc_middle::ty::layout::LayoutOf;
use rustc_middle::mir::interpret::{self, Allocation, ErrorHandled, Scalar as InterpScalar, read_target_uint};
use rustc_middle::mir::interpret::{self, ConstAllocation, ErrorHandled, Scalar as InterpScalar, read_target_uint};
use rustc_span::Span;
use rustc_span::def_id::DefId;
use rustc_target::abi::{self, Align, HasDataLayout, Primitive, Size, WrappingRange};
Expand Down Expand Up @@ -293,7 +293,8 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
}
}

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

pub fn codegen_static_initializer<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, def_id: DefId) -> Result<(RValue<'gcc>, &'tcx Allocation), ErrorHandled> {
pub fn codegen_static_initializer<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, def_id: DefId) -> Result<(RValue<'gcc>, ConstAllocation<'tcx>), ErrorHandled> {
let alloc = cx.tcx.eval_static_initializer(def_id)?;
Ok((const_alloc_to_gcc(cx, alloc), alloc))
}
Expand Down
5 changes: 3 additions & 2 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ pub struct CodegenCx<'gcc, 'tcx> {

/// Cache of emitted const globals (value -> global)
pub const_globals: RefCell<FxHashMap<RValue<'gcc>, RValue<'gcc>>>,

/// Map from the address of a global variable (rvalue) to the global variable itself (lvalue).
/// TODO(antoyo): remove when the rustc API is fixed.
pub global_lvalues: RefCell<FxHashMap<RValue<'gcc>, LValue<'gcc>>>,

/// Cache of constant strings,
pub const_cstr_cache: RefCell<FxHashMap<Symbol, LValue<'gcc>>>,
pub const_str_cache: RefCell<FxHashMap<Symbol, LValue<'gcc>>>,

/// Cache of globals.
pub globals: RefCell<FxHashMap<String, RValue<'gcc>>>,
Expand Down Expand Up @@ -219,7 +220,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
vtables: Default::default(),
const_globals: Default::default(),
global_lvalues: Default::default(),
const_cstr_cache: Default::default(),
const_str_cache: Default::default(),
globals: Default::default(),
scalar_types: Default::default(),
types: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion src/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
}

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

Expand Down
8 changes: 4 additions & 4 deletions src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,20 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
use rustc_target::abi::Abi::*;
let tp_ty = substs.type_at(0);
let layout = self.layout_of(tp_ty).layout;
let _use_integer_compare = match layout.abi {
let _use_integer_compare = match layout.abi() {
Scalar(_) | ScalarPair(_, _) => true,
Uninhabited | Vector { .. } => false,
Aggregate { .. } => {
// For rusty ABIs, small aggregates are actually passed
// as `RegKind::Integer` (see `FnAbi::adjust_for_abi`),
// so we re-use that same threshold here.
layout.size <= self.data_layout().pointer_size * 2
layout.size() <= self.data_layout().pointer_size * 2
}
};

let a = args[0].immediate();
let b = args[1].immediate();
if layout.size.bytes() == 0 {
if layout.size().bytes() == 0 {
self.const_bool(true)
}
/*else if use_integer_compare {
Expand All @@ -289,7 +289,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
let void_ptr_type = self.context.new_type::<*const ()>();
let a_ptr = self.bitcast(a, void_ptr_type);
let b_ptr = self.bitcast(b, void_ptr_type);
let n = self.context.new_cast(None, self.const_usize(layout.size.bytes()), self.sizet_type);
let n = self.context.new_cast(None, self.const_usize(layout.size().bytes()), self.sizet_type);
let builtin = self.context.get_builtin_function("memcmp");
let cmp = self.context.new_call(None, builtin, &[a_ptr, b_ptr, n]);
self.icmp(IntPredicate::IntEQ, cmp, self.const_i32(0))
Expand Down
Loading