diff --git a/example/alloc_system.rs b/example/alloc_system.rs index 5f66ca67f2d4..89661918d05a 100644 --- a/example/alloc_system.rs +++ b/example/alloc_system.rs @@ -156,7 +156,7 @@ mod platform { struct Header(*mut u8); const HEAP_ZERO_MEMORY: DWORD = 0x00000008; unsafe fn get_header<'a>(ptr: *mut u8) -> &'a mut Header { - &mut *(ptr as *mut Header).offset(-1) + &mut *(ptr as *mut Header).sub(1) } unsafe fn align_ptr(ptr: *mut u8, align: usize) -> *mut u8 { let aligned = ptr.add(align - (ptr as usize & (align - 1))); diff --git a/example/mini_core.rs b/example/mini_core.rs index a8435287d9fd..b23ecda35d3e 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -1,6 +1,6 @@ #![feature( no_core, lang_items, intrinsics, unboxed_closures, type_ascription, extern_types, - untagged_unions, decl_macro, rustc_attrs, transparent_unions, auto_traits, + decl_macro, rustc_attrs, transparent_unions, auto_traits, thread_local )] #![no_core] @@ -39,14 +39,14 @@ impl<'a, T: ?Sized+Unsize, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut impl, U: ?Sized> DispatchFromDyn<*const U> for *const T {} // *mut T -> *mut U impl, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {} -impl, U: ?Sized> DispatchFromDyn> for Box {} +impl, U: ?Sized> DispatchFromDyn> for Box {} #[lang = "receiver"] pub trait Receiver {} impl Receiver for &T {} impl Receiver for &mut T {} -impl Receiver for Box {} +impl Receiver for Box {} #[lang = "copy"] pub unsafe trait Copy {} @@ -411,7 +411,15 @@ pub trait FnMut: FnOnce { #[lang = "panic"] #[track_caller] -pub fn panic(_msg: &str) -> ! { +pub fn panic(_msg: &'static str) -> ! { + unsafe { + libc::puts("Panicking\n\0" as *const str as *const u8); + intrinsics::abort(); + } +} + +#[lang = "panic_no_unwind"] +fn panic_no_unwind() -> ! { unsafe { libc::puts("Panicking\n\0" as *const str as *const u8); intrinsics::abort(); @@ -450,17 +458,32 @@ pub trait Deref { pub trait Allocator { } +impl Allocator for () {} + pub struct Global; impl Allocator for Global {} -#[lang = "owned_box"] -pub struct Box< - T: ?Sized, - A: Allocator = Global, ->(*mut T, A); +#[repr(transparent)] +#[rustc_layout_scalar_valid_range_start(1)] +#[rustc_nonnull_optimization_guaranteed] +pub struct NonNull(pub *const T); -impl, U: ?Sized> CoerceUnsized> for Box {} +impl CoerceUnsized> for NonNull where T: Unsize {} +impl DispatchFromDyn> for NonNull where T: Unsize {} + +pub struct Unique { + pub pointer: NonNull, + pub _marker: PhantomData, +} + +impl CoerceUnsized> for Unique where T: Unsize {} +impl DispatchFromDyn> for Unique where T: Unsize {} + +#[lang = "owned_box"] +pub struct Box(Unique, A); + +impl, U: ?Sized, A: Allocator> CoerceUnsized> for Box {} impl Drop for Box { fn drop(&mut self) { @@ -468,7 +491,7 @@ impl Drop for Box { } } -impl Deref for Box { +impl Deref for Box { type Target = T; fn deref(&self) -> &Self::Target { @@ -482,8 +505,8 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { } #[lang = "box_free"] -unsafe fn box_free(ptr: *mut T, alloc: A) { - libc::free(ptr as *mut u8); +unsafe fn box_free(ptr: Unique, _alloc: ()) { + libc::free(ptr.pointer.0 as *mut u8); } #[lang = "drop"] @@ -505,16 +528,18 @@ pub union MaybeUninit { } pub mod intrinsics { + use crate::Sized; + extern "rust-intrinsic" { pub fn abort() -> !; pub fn size_of() -> usize; - pub fn size_of_val(val: *const T) -> usize; + pub fn size_of_val(val: *const T) -> usize; pub fn min_align_of() -> usize; - pub fn min_align_of_val(val: *const T) -> usize; + pub fn min_align_of_val(val: *const T) -> usize; pub fn copy(src: *const T, dst: *mut T, count: usize); pub fn transmute(e: T) -> U; pub fn ctlz_nonzero(x: T) -> T; - pub fn needs_drop() -> bool; + pub fn needs_drop() -> bool; pub fn bitreverse(x: T) -> T; pub fn bswap(x: T) -> T; pub fn write_bytes(dst: *mut T, val: u8, count: usize); diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 69d591565acf..14fd9eeffa6a 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -47,6 +47,11 @@ struct NoisyDrop { inner: NoisyDropInner, } +struct NoisyDropUnsized { + inner: NoisyDropInner, + text: str, +} + struct NoisyDropInner; impl Drop for NoisyDrop { @@ -184,7 +189,9 @@ fn main() { assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8); assert!(!intrinsics::needs_drop::()); + assert!(!intrinsics::needs_drop::<[u8]>()); assert!(intrinsics::needs_drop::()); + assert!(intrinsics::needs_drop::()); Unique { pointer: 0 as *const &str, diff --git a/failing-ui-tests.txt b/failing-ui-tests.txt index 717d0d39331f..0e34110a0603 100644 --- a/failing-ui-tests.txt +++ b/failing-ui-tests.txt @@ -9,28 +9,28 @@ src/test/ui/allocator/xcrate-use.rs src/test/ui/allocator/xcrate-use2.rs src/test/ui/asm/may_unwind.rs src/test/ui/asm/x86_64/const.rs +src/test/ui/asm/x86_64/issue-96797.rs src/test/ui/asm/x86_64/multiple-clobber-abi.rs src/test/ui/async-await/async-fn-size-moved-locals.rs src/test/ui/async-await/async-fn-size-uninit-locals.rs -src/test/ui/backtrace.rs src/test/ui/cfg/cfg-panic.rs src/test/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs src/test/ui/functions-closures/parallel-codegen-closures.rs src/test/ui/generator/size-moved-locals.rs -src/test/ui/issues/issue-32518.rs +src/test/ui/issues/issue-40883.rs src/test/ui/issues/issue-47364.rs -src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs src/test/ui/linkage-attr/linkage1.rs src/test/ui/lto/dylib-works.rs -src/test/ui/mir/mir_heavy_promoted.rs +src/test/ui/macros/rfc-2011-nicer-assert-messages/all-not-available-cases.rs +src/test/ui/macros/rfc-2011-nicer-assert-messages/assert-without-captures-does-not-create-unnecessary-code.rs src/test/ui/numbers-arithmetic/saturating-float-casts.rs src/test/ui/polymorphization/promoted-function.rs +src/test/ui/process/nofile-limit.rs src/test/ui/runtime/rt-explody-panic-payloads.rs src/test/ui/sepcomp/sepcomp-cci.rs src/test/ui/sepcomp/sepcomp-extern.rs src/test/ui/sepcomp/sepcomp-fns-backwards.rs src/test/ui/sepcomp/sepcomp-fns.rs -src/test/ui/sepcomp/sepcomp-lib.rs src/test/ui/sepcomp/sepcomp-statics.rs src/test/ui/simd/generics.rs src/test/ui/simd/intrinsic/float-math-pass.rs diff --git a/patches/0024-core-Disable-portable-simd-test.patch b/patches/0024-core-Disable-portable-simd-test.patch index d5fa1cec061d..7ea0eebe6a12 100644 --- a/patches/0024-core-Disable-portable-simd-test.patch +++ b/patches/0024-core-Disable-portable-simd-test.patch @@ -1,25 +1,25 @@ -From b1ae000f6da1abd3b8e9b80c40bc11c89b8ae93c Mon Sep 17 00:00:00 2001 -From: bjorn3 -Date: Thu, 30 Dec 2021 16:54:40 +0100 -Subject: [PATCH] [core] Disable portable-simd test +From f845df4056f5ba16b9f5bd703460c4ac40ea03b9 Mon Sep 17 00:00:00 2001 +From: Antoni Boucher +Date: Fri, 26 Aug 2022 20:38:58 -0400 +Subject: [PATCH] Edit --- - library/core/tests/lib.rs | 1 - - 1 file changed, 1 deletion(-) + library/core/tests/lib.rs | 2 -- + 1 file changed, 2 deletions(-) diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs -index 06c7be0..359e2e7 100644 +index 59510d3..179bf26 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs -@@ -75,7 +75,6 @@ - #![feature(never_type)] +@@ -77,7 +77,6 @@ #![feature(unwrap_infallible)] #![feature(result_into_ok_or_err)] + #![feature(pointer_byte_offsets)] -#![feature(portable_simd)] #![feature(ptr_metadata)] #![feature(once_cell)] #![feature(option_result_contains)] -@@ -127,7 +126,6 @@ mod pin; +@@ -135,7 +134,6 @@ mod pin; mod pin_macro; mod ptr; mod result; @@ -27,3 +27,6 @@ index 06c7be0..359e2e7 100644 mod slice; mod str; mod str_lossy; +-- +2.26.2.7.g19db9cfb68.dirty + diff --git a/rust-toolchain b/rust-toolchain index b20aeb979ad7..775d9906bf41 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2022-06-06" +channel = "nightly-2022-08-26" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] diff --git a/src/abi.rs b/src/abi.rs index 2c796d0f69e5..0ed3e1fbe93f 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -1,6 +1,6 @@ use gccjit::{ToLValue, ToRValue, Type}; use rustc_codegen_ssa::traits::{AbiBuilderMethods, BaseTypeMethods}; -use rustc_data_structures::stable_set::FxHashSet; +use rustc_data_structures::fx::FxHashSet; use rustc_middle::bug; use rustc_middle::ty::Ty; use rustc_target::abi::call::{CastTarget, FnAbi, PassMode, Reg, RegKind}; diff --git a/src/allocator.rs b/src/allocator.rs index 60985003a9e0..11482c69d594 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -127,7 +127,7 @@ pub(crate) unsafe fn codegen(tcx: TyCtxt<'_>, mods: &mut GccContext, _module_nam 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 = tcx.sess.opts.unstable_opts.oom.should_panic(); let value = context.new_rvalue_from_int(i8, value as i32); global.global_set_initializer_rvalue(value); } diff --git a/src/archive.rs b/src/archive.rs index fac532f3e9c8..f863abdcc97e 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -1,15 +1,13 @@ use std::fs::File; use std::path::{Path, PathBuf}; -use rustc_codegen_ssa::back::archive::ArchiveBuilder; +use rustc_codegen_ssa::back::archive::{ArchiveBuilder, ArchiveBuilderBuilder}; use rustc_session::Session; -use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_session::cstore::DllImport; struct ArchiveConfig<'a> { sess: &'a Session, - dst: PathBuf, use_native_ar: bool, use_gnu_style_archive: bool, } @@ -23,6 +21,35 @@ enum ArchiveEntry { File(PathBuf), } +pub struct ArArchiveBuilderBuilder; + +impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder { + fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box + 'a> { + let config = ArchiveConfig { + sess, + use_native_ar: false, + // FIXME test for linux and System V derivatives instead + use_gnu_style_archive: sess.target.options.archive_format == "gnu", + }; + + Box::new(ArArchiveBuilder { + config, + src_archives: vec![], + entries: vec![], + }) + } + + fn create_dll_import_lib( + &self, + _sess: &Session, + _lib_name: &str, + _dll_imports: &[DllImport], + _tmpdir: &Path, + ) -> PathBuf { + unimplemented!(); + } +} + pub struct ArArchiveBuilder<'a> { config: ArchiveConfig<'a>, src_archives: Vec<(PathBuf, ar::Archive)>, @@ -32,57 +59,6 @@ pub struct ArArchiveBuilder<'a> { } impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { - fn new(sess: &'a Session, output: &Path, input: Option<&Path>) -> Self { - let config = ArchiveConfig { - sess, - dst: output.to_path_buf(), - use_native_ar: false, - // FIXME test for linux and System V derivatives instead - use_gnu_style_archive: sess.target.options.archive_format == "gnu", - }; - - let (src_archives, entries) = if let Some(input) = input { - let mut archive = ar::Archive::new(File::open(input).unwrap()); - let mut entries = Vec::new(); - - let mut i = 0; - while let Some(entry) = archive.next_entry() { - let entry = entry.unwrap(); - entries.push(( - String::from_utf8(entry.header().identifier().to_vec()).unwrap(), - ArchiveEntry::FromArchive { - archive_index: 0, - entry_index: i, - }, - )); - i += 1; - } - - (vec![(input.to_owned(), archive)], entries) - } else { - (vec![], Vec::new()) - }; - - ArArchiveBuilder { - config, - src_archives, - entries, - } - } - - fn src_files(&mut self) -> Vec { - self.entries.iter().map(|(name, _)| name.clone()).collect() - } - - fn remove_file(&mut self, name: &str) { - let index = self - .entries - .iter() - .position(|(entry_name, _)| entry_name == name) - .expect("Tried to remove file not existing in src archive"); - self.entries.remove(index); - } - fn add_file(&mut self, file: &Path) { self.entries.push(( file.file_name().unwrap().to_str().unwrap().to_string(), @@ -90,10 +66,11 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { )); } - fn add_archive(&mut self, archive_path: &Path, mut skip: F) -> std::io::Result<()> - where - F: FnMut(&str) -> bool + 'static, - { + fn add_archive( + &mut self, + archive_path: &Path, + mut skip: Box bool + 'static>, + ) -> std::io::Result<()> { let mut archive = ar::Archive::new(std::fs::File::open(&archive_path)?); let archive_index = self.src_archives.len(); @@ -113,7 +90,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { Ok(()) } - fn build(mut self) { + fn build(mut self: Box, output: &Path) -> bool { use std::process::Command; fn add_file_using_ar(archive: &Path, file: &Path) { @@ -133,19 +110,21 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { } let mut builder = if self.config.use_native_ar { - BuilderKind::NativeAr(&self.config.dst) + BuilderKind::NativeAr(output) } else if self.config.use_gnu_style_archive { BuilderKind::Gnu(ar::GnuBuilder::new( - File::create(&self.config.dst).unwrap(), + File::create(output).unwrap(), self.entries .iter() .map(|(name, _)| name.as_bytes().to_vec()) .collect(), )) } else { - BuilderKind::Bsd(ar::Builder::new(File::create(&self.config.dst).unwrap())) + BuilderKind::Bsd(ar::Builder::new(File::create(output).unwrap())) }; + let any_members = !self.entries.is_empty(); + // Add all files for (entry_name, entry) in self.entries.into_iter() { match entry { @@ -198,17 +177,13 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { std::mem::drop(builder); // Run ranlib to be able to link the archive - let status = std::process::Command::new("ranlib") - .arg(self.config.dst) - .status() - .expect("Couldn't run ranlib"); + let status = + std::process::Command::new("ranlib").arg(output).status().expect("Couldn't run ranlib"); if !status.success() { self.config.sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); } - } - fn inject_dll_import_lib(&mut self, _lib_name: &str, _dll_imports: &[DllImport], _tmpdir: &MaybeTempDir) { - unimplemented!(); + any_members } } diff --git a/src/base.rs b/src/base.rs index 42194b526e64..8cc9581e842c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -121,7 +121,7 @@ pub fn compile_codegen_unit<'tcx>(tcx: TyCtxt<'tcx>, cgu_name: Symbol, supports_ // NOTE: Rust relies on LLVM not doing TBAA (https://github.com/rust-lang/unsafe-code-guidelines/issues/292). context.add_command_line_option("-fno-strict-aliasing"); - if tcx.sess.opts.debugging_opts.function_sections.unwrap_or(tcx.sess.target.function_sections) { + if tcx.sess.opts.unstable_opts.function_sections.unwrap_or(tcx.sess.target.function_sections) { context.add_command_line_option("-ffunction-sections"); context.add_command_line_option("-fdata-sections"); } diff --git a/src/builder.rs b/src/builder.rs index bcbaad39044d..41df7e647b5f 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -30,7 +30,7 @@ use rustc_codegen_ssa::traits::{ OverflowOp, StaticBuilderMethods, }; -use rustc_data_structures::stable_set::FxHashSet; +use rustc_data_structures::fx::FxHashSet; use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; use rustc_middle::ty::layout::{FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, LayoutOfHelpers, TyAndLayout}; use rustc_span::Span; @@ -820,16 +820,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { // TODO(antoyo) } - fn type_metadata(&mut self, _function: RValue<'gcc>, _typeid: String) { - // Unsupported. - } - - fn typeid_metadata(&mut self, _typeid: String) -> RValue<'gcc> { - // Unsupported. - self.context.new_rvalue_from_int(self.int_type, 0) - } - - fn store(&mut self, val: RValue<'gcc>, ptr: RValue<'gcc>, align: Align) -> RValue<'gcc> { self.store_with_flags(val, ptr, align, MemFlags::empty()) } @@ -1195,6 +1185,15 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { fn atomic_cmpxchg(&mut self, dst: RValue<'gcc>, cmp: RValue<'gcc>, src: RValue<'gcc>, order: AtomicOrdering, failure_order: AtomicOrdering, weak: bool) -> RValue<'gcc> { let expected = self.current_func().new_local(None, cmp.get_type(), "expected"); self.llbb().add_assignment(None, expected, cmp); + // NOTE: gcc doesn't support a failure memory model that is stronger than the success + // memory model. + let order = + if failure_order as i32 > order as i32 { + failure_order + } + else { + order + }; let success = self.compare_exchange(dst, expected, src, order, failure_order, weak); let pair_type = self.cx.type_struct(&[src.get_type(), self.bool_type], false); diff --git a/src/callee.rs b/src/callee.rs index d7bbf1d34ef1..be7d48b2279a 100644 --- a/src/callee.rs +++ b/src/callee.rs @@ -2,7 +2,7 @@ use gccjit::{FnAttribute, Visibility}; use gccjit::{FunctionType, RValue}; use rustc_codegen_ssa::traits::BaseTypeMethods; -use rustc_middle::ty::{self, Instance, TypeFoldable}; +use rustc_middle::ty::{self, Instance, TypeVisitable}; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt}; use crate::abi::FnAbiGccExt; diff --git a/src/common.rs b/src/common.rs index 9c55692dea12..1d44dc486683 100644 --- a/src/common.rs +++ b/src/common.rs @@ -9,10 +9,8 @@ use rustc_codegen_ssa::traits::{ StaticMethods, }; use rustc_middle::mir::Mutability; -use rustc_middle::ty::ScalarInt; use rustc_middle::ty::layout::{TyAndLayout, LayoutOf}; use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar}; -use rustc_span::Symbol; use rustc_target::abi::{self, HasDataLayout, Pointer, Size}; use crate::consts::const_alloc_to_gcc; @@ -125,12 +123,15 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> { self.context.new_rvalue_from_double(typ, val) } - fn const_str(&self, s: Symbol) -> (RValue<'gcc>, RValue<'gcc>) { - 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(); + fn const_str(&self, s: &str) -> (RValue<'gcc>, RValue<'gcc>) { + let str_global = *self + .const_str_cache + .borrow_mut() + .raw_entry_mut() + .from_key(s) + .or_insert_with(|| (s.to_owned(), self.global_string(s))) + .1; + let len = s.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)), ); @@ -157,13 +158,13 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> { None } + fn zst_to_backend(&self, _ty: Type<'gcc>) -> RValue<'gcc> { + self.const_undef(self.type_ix(0)) + } + fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, ty: Type<'gcc>) -> RValue<'gcc> { let bitsize = if layout.is_bool() { 1 } else { layout.size(self).bits() }; match cv { - Scalar::Int(ScalarInt::ZST) => { - assert_eq!(0, layout.size(self).bytes()); - self.const_undef(self.type_ix(0)) - } Scalar::Int(int) => { let data = int.assert_bits(layout.size(self)); @@ -210,6 +211,11 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> { GlobalAlloc::Function(fn_instance) => { self.get_fn_addr(fn_instance) }, + GlobalAlloc::VTable(ty, trait_ref) => { + let alloc = self.tcx.global_alloc(self.tcx.vtable_allocation((ty, trait_ref))).unwrap_memory(); + let init = const_alloc_to_gcc(self, alloc); + self.static_addr_of(init, alloc.inner().align, None) + } GlobalAlloc::Static(def_id) => { assert!(self.tcx.is_static(def_id)); self.get_static(def_id).get_address(None) diff --git a/src/context.rs b/src/context.rs index 9879e31c2ea5..2699559dc2ad 100644 --- a/src/context.rs +++ b/src/context.rs @@ -13,7 +13,7 @@ use rustc_middle::mir::mono::CodegenUnit; use rustc_middle::ty::{self, Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt}; use rustc_middle::ty::layout::{FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, TyAndLayout, LayoutOfHelpers}; use rustc_session::Session; -use rustc_span::{Span, Symbol}; +use rustc_span::Span; use rustc_target::abi::{call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx}; use rustc_target::spec::{HasTargetSpec, Target, TlsModel}; @@ -99,7 +99,7 @@ pub struct CodegenCx<'gcc, 'tcx> { pub global_lvalues: RefCell, LValue<'gcc>>>, /// Cache of constant strings, - pub const_str_cache: RefCell>>, + pub const_str_cache: RefCell>>, /// Cache of globals. pub globals: RefCell>>, diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index 1315edf0891e..e3461b97973e 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -356,6 +356,16 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { self.context.new_rvalue_from_int(self.int_type, 0) } + fn type_checked_load( + &mut self, + _llvtable: Self::Value, + _vtable_byte_offset: u64, + _typeid: Self::Value, + ) -> Self::Value { + // Unsupported. + self.context.new_rvalue_from_int(self.int_type, 0) + } + fn va_start(&mut self, _va_list: RValue<'gcc>) -> RValue<'gcc> { unimplemented!(); } diff --git a/src/intrinsic/simd.rs b/src/intrinsic/simd.rs index 9c2a1401a154..dbf6ee6d285d 100644 --- a/src/intrinsic/simd.rs +++ b/src/intrinsic/simd.rs @@ -395,9 +395,6 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(bx: &mut Builder<'a, 'gcc, 'tcx>, args: &[OperandRef<'tcx, RValue<'gcc>>], ) -> Result, ()> { macro_rules! emit_error { - ($msg: tt) => { - emit_error!($msg, ) - }; ($msg: tt, $($fmt: tt)*) => { span_invalid_monomorphization_error( bx.sess(), span, diff --git a/src/lib.rs b/src/lib.rs index b3cbf344ad13..e43ee5cf21dc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,14 @@ * TODO(antoyo): remove the patches. */ -#![feature(rustc_private, decl_macro, associated_type_bounds, never_type, trusted_len)] +#![feature( + rustc_private, + decl_macro, + associated_type_bounds, + never_type, + trusted_len, + hash_raw_entry +)] #![allow(broken_intra_doc_links)] #![recursion_limit="256"] #![warn(rust_2018_idioms)] @@ -128,15 +135,16 @@ impl CodegenBackend for GccCodegenBackend { fn link(&self, sess: &Session, codegen_results: CodegenResults, outputs: &OutputFilenames) -> Result<(), ErrorGuaranteed> { use rustc_codegen_ssa::back::link::link_binary; - link_binary::>( + link_binary( sess, + &crate::archive::ArArchiveBuilderBuilder, &codegen_results, outputs, ) } - fn target_features(&self, sess: &Session) -> Vec { - target_features(sess) + fn target_features(&self, sess: &Session, allow_unstable: bool) -> Vec { + target_features(sess, allow_unstable) } } @@ -293,12 +301,12 @@ pub fn target_cpu(sess: &Session) -> &str { } } -pub fn target_features(sess: &Session) -> Vec { +pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec { supported_target_features(sess) .iter() .filter_map( |&(feature, gate)| { - if sess.is_nightly_build() || gate.is_none() { Some(feature) } else { None } + if sess.is_nightly_build() || allow_unstable || gate.is_none() { Some(feature) } else { None } }, ) .filter(|_feature| { diff --git a/src/mono_item.rs b/src/mono_item.rs index d0d6b9b5bfe3..ce439d339b6b 100644 --- a/src/mono_item.rs +++ b/src/mono_item.rs @@ -4,7 +4,7 @@ use rustc_codegen_ssa::traits::PreDefineMethods; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::mono::{Linkage, Visibility}; -use rustc_middle::ty::{self, Instance, TypeFoldable}; +use rustc_middle::ty::{self, Instance, TypeVisitable}; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf}; use crate::attributes; diff --git a/src/type_.rs b/src/type_.rs index b85aad7c00b3..c97e9586005b 100644 --- a/src/type_.rs +++ b/src/type_.rs @@ -1,7 +1,7 @@ use std::convert::TryInto; use gccjit::{RValue, Struct, Type}; -use rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods}; +use rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods, TypeMembershipMethods}; use rustc_codegen_ssa::common::TypeKind; use rustc_middle::{bug, ty}; use rustc_middle::ty::layout::TyAndLayout; @@ -290,3 +290,14 @@ pub fn struct_fields<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout (result, packed) } + +impl<'gcc, 'tcx> TypeMembershipMethods<'tcx> for CodegenCx<'gcc, 'tcx> { + fn set_type_metadata(&self, _function: RValue<'gcc>, _typeid: String) { + // Unsupported. + } + + fn typeid_metadata(&self, _typeid: String) -> RValue<'gcc> { + // Unsupported. + self.context.new_rvalue_from_int(self.int_type, 0) + } +} diff --git a/src/type_of.rs b/src/type_of.rs index c7aa4239c7fa..29d394dbba4a 100644 --- a/src/type_of.rs +++ b/src/type_of.rs @@ -3,7 +3,7 @@ use std::fmt::Write; use gccjit::{Struct, Type}; use crate::rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods, LayoutTypeMethods}; use rustc_middle::bug; -use rustc_middle::ty::{self, Ty, TypeFoldable}; +use rustc_middle::ty::{self, Ty, TypeVisitable}; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout}; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_target::abi::{self, Abi, F32, F64, FieldsShape, Int, Integer, Pointer, PointeeInfo, Size, TyAbiInterface, Variants}; diff --git a/test.sh b/test.sh index 06f608ad422a..ed43c645bd2d 100755 --- a/test.sh +++ b/test.sh @@ -321,12 +321,14 @@ EOF git checkout -- src/test/ui/issues/auxiliary/issue-3136-a.rs # contains //~ERROR, but shouldn't be removed rm -r src/test/ui/{abi*,extern/,panic-runtime/,panics/,unsized-locals/,proc-macro/,threads-sendsync/,thinlto/,borrowck/,chalkify/bugs/,test*,*lto*.rs,consts/const-float-bits-reject-conv.rs,consts/issue-miri-1910.rs} || true + rm src/test/ui/mir/mir_heavy_promoted.rs # this tests is oom-killed in the CI. for test in $(rg --files-with-matches "catch_unwind|should_panic|thread|lto" src/test/ui); do rm $test done git checkout src/test/ui/lto/auxiliary/dylib.rs git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice.rs git checkout src/test/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs + git checkout src/test/ui/macros/rfc-2011-nicer-assert-messages/auxiliary/common.rs RUSTC_ARGS="-Zpanic-abort-tests -Csymbol-mangling-version=v0 -Zcodegen-backend="$(pwd)"/../target/"$CHANNEL"/librustc_codegen_gcc."$dylib_ext" --sysroot "$(pwd)"/../build_sysroot/sysroot -Cpanic=abort" @@ -338,7 +340,7 @@ EOF xargs -a ../failing-ui-tests.txt -d'\n' rm else # Removing all tests. - find src/test/ui -type f -name '*.rs' -exec rm {} \; + find src/test/ui -type f -name '*.rs' -not -path '*/auxiliary/*' -delete # Putting back only the failing ones. xargs -a ../failing-ui-tests.txt -d'\n' git checkout -- fi @@ -354,7 +356,7 @@ EOF count=$((count + 1)) split -d -l $count -a 1 ui_tests ui_tests.split # Removing all tests. - find src/test/ui -type f -name '*.rs' -not -path "*/auxiliary/*" -exec rm {} \; + find src/test/ui -type f -name '*.rs' -not -path "*/auxiliary/*" -delete # Putting back only the ones we want to test. xargs -a "ui_tests.split$current_part" -d'\n' git checkout -- fi @@ -372,7 +374,7 @@ function test_successful_rustc() { } function clean_ui_tests() { - find rust/build/x86_64-unknown-linux-gnu/test/ui/ -name stamp -exec rm -rf {} \; + find rust/build/x86_64-unknown-linux-gnu/test/ui/ -name stamp -delete } function all() { diff --git a/tests/run/array.rs b/tests/run/array.rs index 8b621d8a3530..c53d98340f04 100644 --- a/tests/run/array.rs +++ b/tests/run/array.rs @@ -79,7 +79,7 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { #[lang = "panic"] #[track_caller] #[no_mangle] -pub fn panic(_msg: &str) -> ! { +pub fn panic(_msg: &'static str) -> ! { unsafe { libc::puts("Panicking\0" as *const str as *const u8); intrinsics::abort(); diff --git a/tests/run/assign.rs b/tests/run/assign.rs index eb38a8a38357..b95a7b714153 100644 --- a/tests/run/assign.rs +++ b/tests/run/assign.rs @@ -64,7 +64,7 @@ mod intrinsics { #[lang = "panic"] #[track_caller] #[no_mangle] -pub fn panic(_msg: &str) -> ! { +pub fn panic(_msg: &'static str) -> ! { unsafe { libc::puts("Panicking\0" as *const str as *const u8); libc::fflush(libc::stdout); diff --git a/tests/run/closure.rs b/tests/run/closure.rs index 7121a5f0d522..4d01d879dc1d 100644 --- a/tests/run/closure.rs +++ b/tests/run/closure.rs @@ -177,7 +177,7 @@ impl Add for isize { #[lang = "panic"] #[track_caller] #[no_mangle] -pub fn panic(_msg: &str) -> ! { +pub fn panic(_msg: &'static str) -> ! { unsafe { libc::puts("Panicking\0" as *const str as *const u8); intrinsics::abort(); diff --git a/tests/run/condition.rs b/tests/run/condition.rs index 6a2e2d5bb11a..38b3084cb6c7 100644 --- a/tests/run/condition.rs +++ b/tests/run/condition.rs @@ -82,7 +82,7 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { #[lang = "panic"] #[track_caller] #[no_mangle] -pub fn panic(_msg: &str) -> ! { +pub fn panic(_msg: &'static str) -> ! { unsafe { libc::puts("Panicking\0" as *const str as *const u8); intrinsics::abort(); diff --git a/tests/run/fun_ptr.rs b/tests/run/fun_ptr.rs index a226fff79e51..995fc5ca5d23 100644 --- a/tests/run/fun_ptr.rs +++ b/tests/run/fun_ptr.rs @@ -76,7 +76,7 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { #[lang = "panic"] #[track_caller] #[no_mangle] -pub fn panic(_msg: &str) -> ! { +pub fn panic(_msg: &'static str) -> ! { unsafe { libc::puts("Panicking\0" as *const str as *const u8); intrinsics::abort(); diff --git a/tests/run/int_overflow.rs b/tests/run/int_overflow.rs index ea2c5add962a..4ca623625395 100644 --- a/tests/run/int_overflow.rs +++ b/tests/run/int_overflow.rs @@ -62,7 +62,7 @@ mod intrinsics { #[lang = "panic"] #[track_caller] #[no_mangle] -pub fn panic(_msg: &str) -> ! { +pub fn panic(_msg: &'static str) -> ! { unsafe { // Panicking is expected iff overflow checking is enabled. #[cfg(debug_assertions)] diff --git a/tests/run/mut_ref.rs b/tests/run/mut_ref.rs index 52de20021f3e..814bb1a612e4 100644 --- a/tests/run/mut_ref.rs +++ b/tests/run/mut_ref.rs @@ -66,7 +66,7 @@ mod intrinsics { #[lang = "panic"] #[track_caller] #[no_mangle] -pub fn panic(_msg: &str) -> ! { +pub fn panic(_msg: &'static str) -> ! { unsafe { libc::puts("Panicking\0" as *const str as *const u8); libc::fflush(libc::stdout); diff --git a/tests/run/operations.rs b/tests/run/operations.rs index e078b37b4aba..affe12067ffe 100644 --- a/tests/run/operations.rs +++ b/tests/run/operations.rs @@ -72,7 +72,7 @@ mod intrinsics { #[lang = "panic"] #[track_caller] #[no_mangle] -pub fn panic(_msg: &str) -> ! { +pub fn panic(_msg: &'static str) -> ! { unsafe { libc::puts("Panicking\0" as *const str as *const u8); libc::fflush(libc::stdout); diff --git a/tests/run/ptr_cast.rs b/tests/run/ptr_cast.rs index 6ac099ea145c..08481739a7f9 100644 --- a/tests/run/ptr_cast.rs +++ b/tests/run/ptr_cast.rs @@ -76,7 +76,7 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { #[lang = "panic"] #[track_caller] #[no_mangle] -pub fn panic(_msg: &str) -> ! { +pub fn panic(_msg: &'static str) -> ! { unsafe { libc::puts("Panicking\0" as *const str as *const u8); intrinsics::abort();