From 9a6b75515e64d943d0812c4ace5eab570dfded78 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Sat, 27 Aug 2022 09:22:17 -0400 Subject: [PATCH] Fix merge conflicts --- .github/workflows/ci.yml | 5 ++ example/mini_core.rs | 57 +++++++++++++------ ...0024-core-Disable-portable-simd-test.patch | 24 ++++---- rust-toolchain | 2 +- src/builder.rs | 9 +++ 5 files changed, 70 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4be75efd73a..8b36fa0c1c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,11 +56,13 @@ jobs: echo $(readlink -f gcc-build) > gcc_path # NOTE: the filename is still libgccjit.so even when the artifact name is different. ln gcc-build/libgccjit.so gcc-build/libgccjit.so.0 + - name: Set env run: | echo "LIBRARY_PATH=$(cat gcc_path)" >> $GITHUB_ENV echo "LD_LIBRARY_PATH=$(cat gcc_path)" >> $GITHUB_ENV echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV + - name: Set RUST_COMPILER_RT_ROOT run: echo "RUST_COMPILER_RT_ROOT="${{ env.workspace }}/llvm/compiler-rt >> $GITHUB_ENV @@ -108,11 +110,13 @@ jobs: ./build.sh ${{ matrix.libgccjit_version.extra }} cargo test ${{ matrix.libgccjit_version.extra }} ./clean_all.sh + - name: Prepare dependencies run: | git config --global user.email "user@example.com" git config --global user.name "User" ./prepare.sh + # Compile is a separate step, as the actions-rs/cargo action supports error annotations - name: Compile uses: actions-rs/cargo@v1.0.3 @@ -127,6 +131,7 @@ jobs: - name: Run tests run: | ./test.sh --release --clean --build-sysroot ${{ matrix.commands }} ${{ matrix.libgccjit_version.extra }} + duplicates: runs-on: ubuntu-latest steps: diff --git a/example/mini_core.rs b/example/mini_core.rs index ddcbb0d9fc7..b23ecda35d3 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 @@ fn drop(&mut self) { } } -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/patches/0024-core-Disable-portable-simd-test.patch b/patches/0024-core-Disable-portable-simd-test.patch index c59a40df039..7ea0eebe6a1 100644 --- a/patches/0024-core-Disable-portable-simd-test.patch +++ b/patches/0024-core-Disable-portable-simd-test.patch @@ -1,24 +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; @@ -26,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 b20aeb979ad..775d9906bf4 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/builder.rs b/src/builder.rs index 3608b97fcf6..41df7e647b5 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1185,6 +1185,15 @@ fn catch_switch( 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);