diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fd27654dc41..1c99e5e2bc28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,9 +19,9 @@ jobs: fail-fast: false matrix: libgccjit_version: - - { gcc: "libgccjit.so", extra: "", artifacts_branch: "master" } - - { gcc: "libgccjit_without_int128.so", extra: "", artifacts_branch: "master-without-128bit-integers" } - - { gcc: "libgccjit12.so", extra: "--no-default-features", artifacts_branch: "gcc12" } + - { gcc: "libgccjit.so", extra: "", env_extra: "", artifacts_branch: "master" } + - { gcc: "libgccjit_without_int128.so", extra: "", env_extra: "", artifacts_branch: "master-without-128bit-integers" } + - { gcc: "libgccjit12.so", extra: "--no-default-features", env_extra: "TEST_FLAGS='-Cpanic=abort -Zpanic-abort-tests'", artifacts_branch: "gcc12" } commands: [ "--mini-tests", "--std-tests", @@ -120,7 +120,7 @@ jobs: - name: Build run: | ./prepare_build.sh - ./build.sh ${{ matrix.libgccjit_version.extra }} + ${{ matrix.libgccjit_version.env_extra }} ./build.sh ${{ matrix.libgccjit_version.extra }} cargo test ${{ matrix.libgccjit_version.extra }} ./clean_all.sh @@ -143,7 +143,7 @@ jobs: - name: Run tests run: | - ./test.sh --release --clean --build-sysroot ${{ matrix.commands }} ${{ matrix.libgccjit_version.extra }} + ${{ matrix.libgccjit_version.env_extra }} ./test.sh --release --clean --build-sysroot ${{ matrix.commands }} ${{ matrix.libgccjit_version.extra }} duplicates: runs-on: ubuntu-latest diff --git a/config.sh b/config.sh index 6bad0586c5ba..166e83901c4f 100644 --- a/config.sh +++ b/config.sh @@ -38,7 +38,7 @@ if [[ "$HOST_TRIPLE" != "$TARGET_TRIPLE" ]]; then fi fi -export RUSTFLAGS="$CG_RUSTFLAGS $linker -Csymbol-mangling-version=v0 -Cdebuginfo=2 -Clto=off -Zcodegen-backend=$(pwd)/target/${CHANNEL:-debug}/librustc_codegen_gcc.$dylib_ext --sysroot $(pwd)/build_sysroot/sysroot" +export RUSTFLAGS="$CG_RUSTFLAGS $linker -Csymbol-mangling-version=v0 -Cdebuginfo=2 -Clto=off -Zcodegen-backend=$(pwd)/target/${CHANNEL:-debug}/librustc_codegen_gcc.$dylib_ext --sysroot $(pwd)/build_sysroot/sysroot $TEST_FLAGS" # FIXME(antoyo): remove once the atomic shim is gone if [[ `uname` == 'Darwin' ]]; then diff --git a/src/builder.rs b/src/builder.rs index 080a306e70eb..0150f5ba8c14 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -13,7 +13,7 @@ use gccjit::{ RValue, ToRValue, Type, - UnaryOp, FunctionType, + UnaryOp, }; use rustc_codegen_ssa::MemFlags; use rustc_codegen_ssa::common::{AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope}; @@ -476,11 +476,6 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { self.block.end_with_jump(None, then); - // NOTE: since jumps were added in a place rustc does not expect, the current blocks in the - // state need to be updated. - // FIXME: not sure it's actually needed. - self.switch_to_block(then); - return_value.to_rvalue() } @@ -1194,12 +1189,15 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { aggregate_value } - fn set_personality_fn(&mut self, personality: RValue<'gcc>) { - let personality = self.rvalue_as_function(personality); + fn set_personality_fn(&mut self, _personality: RValue<'gcc>) { #[cfg(feature="master")] - self.current_func().set_personality_function(personality); + { + let personality = self.rvalue_as_function(_personality); + self.current_func().set_personality_function(personality); + } } + #[cfg(feature="master")] fn cleanup_landing_pad(&mut self, _ty: Type<'gcc>, pers_fn: RValue<'gcc>) -> RValue<'gcc> { self.set_personality_fn(pers_fn); @@ -1223,16 +1221,33 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { value.to_rvalue() } + #[cfg(not(feature="master"))] + fn cleanup_landing_pad(&mut self, _ty: Type<'gcc>, _pers_fn: RValue<'gcc>) -> RValue<'gcc> { + let field1 = self.context.new_field(None, self.u8_type.make_pointer(), "landing_pad_field_1"); + let field2 = self.context.new_field(None, self.i32_type, "landing_pad_field_1"); + let struct_type = self.context.new_struct_type(None, "landing_pad", &[field1, field2]); + self.current_func().new_local(None, struct_type.as_type(), "landing_pad") + .to_rvalue() + } + + #[cfg(feature="master")] fn resume(&mut self, exn: RValue<'gcc>) { // TODO: check if this is normal that we need to dereference the value. + // NOTE: the type is wrong, so in order to get a pointer for parameter, cast it to a + // pointer of pointer that is later dereferenced. + let exn_type = exn.get_type().make_pointer(); + let exn = self.context.new_cast(None, exn, exn_type); let exn = exn.dereference(None).to_rvalue(); - let param = self.context.new_parameter(None, exn.get_type(), "exn"); - // TODO(antoyo): should we call __builtin_unwind_resume instead? This might actually be the same. - let unwind_resume = self.context.new_function(None, FunctionType::Extern, self.type_void(), &[param], "_Unwind_Resume", false); + let unwind_resume = self.context.get_target_builtin_function("__builtin_unwind_resume"); self.llbb().add_eval(None, self.context.new_call(None, unwind_resume, &[exn])); self.unreachable(); } + #[cfg(not(feature="master"))] + fn resume(&mut self, _exn: RValue<'gcc>) { + self.unreachable(); + } + fn cleanup_pad(&mut self, _parent: Option>, _args: &[RValue<'gcc>]) -> Funclet { unimplemented!(); } diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs index fa78325ec9d1..46471096e910 100644 --- a/src/intrinsic/mod.rs +++ b/src/intrinsic/mod.rs @@ -1,6 +1,7 @@ pub mod llvm; mod simd; +#[cfg(feature="master")] use std::iter; use gccjit::{ComparisonOp, Function, RValue, ToRValue, Type, UnaryOp, FunctionType}; @@ -9,16 +10,24 @@ use rustc_codegen_ssa::base::wants_msvc_seh; use rustc_codegen_ssa::common::{IntPredicate, span_invalid_monomorphization_error}; use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; use rustc_codegen_ssa::mir::place::PlaceRef; -use rustc_codegen_ssa::traits::{ArgAbiMethods, BaseTypeMethods, BuilderMethods, ConstMethods, DerivedTypeMethods, IntrinsicCallMethods, MiscMethods}; +use rustc_codegen_ssa::traits::{ArgAbiMethods, BaseTypeMethods, BuilderMethods, ConstMethods, IntrinsicCallMethods}; +#[cfg(feature="master")] +use rustc_codegen_ssa::traits::{DerivedTypeMethods, MiscMethods}; use rustc_middle::bug; use rustc_middle::ty::{self, Instance, Ty}; -use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf}; +use rustc_middle::ty::layout::LayoutOf; +#[cfg(feature="master")] +use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt}; use rustc_span::{Span, Symbol, symbol::kw, sym}; use rustc_target::abi::HasDataLayout; use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode}; -use rustc_target::spec::{abi::Abi, PanicStrategy}; +use rustc_target::spec::PanicStrategy; +#[cfg(feature="master")] +use rustc_target::spec::abi::Abi; -use crate::abi::{FnAbiGccExt, GccType}; +use crate::abi::GccType; +#[cfg(feature="master")] +use crate::abi::FnAbiGccExt; use crate::builder::Builder; use crate::common::{SignType, TypeReflection}; use crate::context::CodegenCx; @@ -1117,7 +1126,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { } } -fn try_intrinsic<'a, 'b, 'gcc, 'tcx>(bx: &'b mut Builder<'a, 'gcc, 'tcx>, try_func: RValue<'gcc>, data: RValue<'gcc>, catch_func: RValue<'gcc>, dest: RValue<'gcc>) { +fn try_intrinsic<'a, 'b, 'gcc, 'tcx>(bx: &'b mut Builder<'a, 'gcc, 'tcx>, try_func: RValue<'gcc>, data: RValue<'gcc>, _catch_func: RValue<'gcc>, dest: RValue<'gcc>) { if bx.sess().panic_strategy() == PanicStrategy::Abort { bx.call(bx.type_void(), try_func, &[data], None); // Return 0 unconditionally from the intrinsic call; @@ -1129,7 +1138,10 @@ fn try_intrinsic<'a, 'b, 'gcc, 'tcx>(bx: &'b mut Builder<'a, 'gcc, 'tcx>, try_fu unimplemented!(); } else { - codegen_gnu_try(bx, try_func, data, catch_func, dest); + #[cfg(feature="master")] + codegen_gnu_try(bx, try_func, data, _catch_func, dest); + #[cfg(not(feature="master"))] + unimplemented!(); } } @@ -1144,6 +1156,7 @@ fn try_intrinsic<'a, 'b, 'gcc, 'tcx>(bx: &'b mut Builder<'a, 'gcc, 'tcx>, try_fu // function calling it, and that function may already have other personality // functions in play. By calling a shim we're guaranteed that our shim will have // the right personality function. +#[cfg(feature="master")] fn codegen_gnu_try<'gcc>(bx: &mut Builder<'_, 'gcc, '_>, try_func: RValue<'gcc>, data: RValue<'gcc>, catch_func: RValue<'gcc>, dest: RValue<'gcc>) { //use std::ops::Deref; //let cx: &CodegenCx<'gcc, '_> = bx.deref(); @@ -1210,6 +1223,7 @@ fn codegen_gnu_try<'gcc>(bx: &mut Builder<'_, 'gcc, '_>, try_func: RValue<'gcc>, // catch exceptions. // // This function is only generated once and is then cached. +#[cfg(feature="master")] fn get_rust_try_fn<'a, 'gcc, 'tcx>(cx: &'a CodegenCx<'gcc, 'tcx>, codegen: &mut dyn FnMut(Builder<'a, 'gcc, 'tcx>)) -> (Type<'gcc>, Function<'gcc>) { if let Some(llfn) = cx.rust_try_fn.get() { return llfn; @@ -1249,6 +1263,7 @@ fn get_rust_try_fn<'a, 'gcc, 'tcx>(cx: &'a CodegenCx<'gcc, 'tcx>, codegen: &mut // Helper function to give a Block to a closure to codegen a shim function. // This is currently primarily used for the `try` intrinsic functions above. +#[cfg(feature="master")] fn gen_fn<'a, 'gcc, 'tcx>(cx: &'a CodegenCx<'gcc, 'tcx>, name: &str, rust_fn_sig: ty::PolyFnSig<'tcx>, codegen: &mut dyn FnMut(Builder<'a, 'gcc, 'tcx>)) -> (Type<'gcc>, Function<'gcc>) { let fn_abi = cx.fn_abi_of_fn_ptr(rust_fn_sig, ty::List::empty()); let (typ, _, _, _) = fn_abi.gcc_type(cx); diff --git a/test.sh b/test.sh index 5604fd4ff94b..25f5a3a419ef 100755 --- a/test.sh +++ b/test.sh @@ -191,11 +191,11 @@ function std_tests() { $RUN_WRAPPER ./target/out/std_example --target $TARGET_TRIPLE echo "[AOT] subslice-patterns-const-eval" - $RUSTC example/subslice-patterns-const-eval.rs --crate-type bin --target $TARGET_TRIPLE + $RUSTC example/subslice-patterns-const-eval.rs --crate-type bin $TEST_FLAGS --target $TARGET_TRIPLE $RUN_WRAPPER ./target/out/subslice-patterns-const-eval echo "[AOT] track-caller-attribute" - $RUSTC example/track-caller-attribute.rs --crate-type bin --target $TARGET_TRIPLE + $RUSTC example/track-caller-attribute.rs --crate-type bin $TEST_FLAGS --target $TARGET_TRIPLE $RUN_WRAPPER ./target/out/track-caller-attribute echo "[BUILD] mod_bench" @@ -338,10 +338,9 @@ function test_rustc() { 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 -r src/test/ui/{abi*,extern/,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. - # TODO: re-enable panics tests. - for test in $(rg --files-with-matches "catch_unwind|should_panic|thread|lto" src/test/ui); do + for test in $(rg --files-with-matches "thread|lto" src/test/ui); do rm $test done git checkout src/test/ui/lto/auxiliary/dylib.rs