Fix tests
This commit is contained in:
parent
b4f83c6ed8
commit
a2f499f05f
11 changed files with 59 additions and 56 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -35,7 +35,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "gccjit"
|
||||
version = "1.0.0"
|
||||
source = "git+https://github.com/antoyo/gccjit.rs#1bd270d0d130fe31807cfbe509ca095c082e5848"
|
||||
source = "git+https://github.com/antoyo/gccjit.rs#eefb8c662d61477f34b7c32d26bcda5f1ef08432"
|
||||
dependencies = [
|
||||
"gccjit_sys",
|
||||
]
|
||||
|
|
@ -43,7 +43,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "gccjit_sys"
|
||||
version = "0.0.1"
|
||||
source = "git+https://github.com/antoyo/gccjit.rs#1bd270d0d130fe31807cfbe509ca095c082e5848"
|
||||
source = "git+https://github.com/antoyo/gccjit.rs#eefb8c662d61477f34b7c32d26bcda5f1ef08432"
|
||||
dependencies = [
|
||||
"libc 0.1.12",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -60,3 +60,6 @@ codegen_gcc_invalid_monomorphization_unsupported_cast =
|
|||
|
||||
codegen_gcc_invalid_monomorphization_unsupported_operation =
|
||||
invalid monomorphization of `{$name}` intrinsic: unsupported operation on `{$in_ty}` with element `{$in_elem}`
|
||||
|
||||
codegen_gcc_invalid_minimum_alignment =
|
||||
invalid minimum global alignment: {$err}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ new file mode 100644
|
|||
index 0000000..46fd999
|
||||
--- /dev/null
|
||||
+++ b/library/core/tests/Cargo.toml
|
||||
@@ -0,0 +1,8 @@
|
||||
@@ -0,0 +1,12 @@
|
||||
+[package]
|
||||
+name = "core"
|
||||
+version = "0.0.0"
|
||||
|
|
@ -27,37 +27,18 @@ index 0000000..46fd999
|
|||
+[lib]
|
||||
+name = "coretests"
|
||||
+path = "lib.rs"
|
||||
diff --git a/library/core/tests/num/flt2dec/mod.rs b/library/core/tests/num/flt2dec/mod.rs
|
||||
index a35897e..f0bf645 100644
|
||||
--- a/library/core/tests/num/flt2dec/mod.rs
|
||||
+++ b/library/core/tests/num/flt2dec/mod.rs
|
||||
@@ -13,7 +13,6 @@ mod strategy {
|
||||
mod dragon;
|
||||
mod grisu;
|
||||
}
|
||||
-mod random;
|
||||
|
||||
pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
|
||||
match decode(v).1 {
|
||||
diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs
|
||||
index 6609bc3..241b497 100644
|
||||
--- a/library/core/tests/slice.rs
|
||||
+++ b/library/core/tests/slice.rs
|
||||
@@ -1209,6 +1209,7 @@ fn brute_force_rotate_test_1() {
|
||||
}
|
||||
}
|
||||
|
||||
+/*
|
||||
#[test]
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn sort_unstable() {
|
||||
@@ -1394,6 +1395,7 @@ fn partition_at_index() {
|
||||
v.select_nth_unstable(0);
|
||||
assert!(v == [0xDEADBEEF]);
|
||||
}
|
||||
+*/
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "index 0 greater than length of slice")]
|
||||
+
|
||||
+[dependencies]
|
||||
+rand = { version = "0.8.5", default-features = false }
|
||||
+rand_xorshift = { version = "0.3.0", default-features = false }
|
||||
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
|
||||
index 42a26ae..5ac1042 100644
|
||||
--- a/library/core/tests/lib.rs
|
||||
+++ b/library/core/tests/lib.rs
|
||||
@@ -1,3 +1,4 @@
|
||||
+#![cfg(test)]
|
||||
#![feature(alloc_layout_extra)]
|
||||
#![feature(array_chunks)]
|
||||
#![feature(array_methods)]
|
||||
--
|
||||
2.21.0 (Apple Git-122)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
[toolchain]
|
||||
channel = "nightly-2023-02-28"
|
||||
channel = "nightly-2023-03-02"
|
||||
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
||||
|
|
|
|||
|
|
@ -1228,12 +1228,8 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||
|
||||
#[cfg(feature="master")]
|
||||
fn resume(&mut self, exn0: RValue<'gcc>, _exn1: RValue<'gcc>) {
|
||||
// TODO(antoyo): 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 = exn0.get_type().make_pointer();
|
||||
let exn_type = exn0.get_type();
|
||||
let exn = self.context.new_cast(None, exn0, exn_type);
|
||||
let exn = exn.dereference(None).to_rvalue();
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||
pub fn bytes_in_context<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, bytes: &[u8]) -> RValue<'gcc> {
|
||||
let context = &cx.context;
|
||||
let byte_type = context.new_type::<u8>();
|
||||
let typ = context.new_array_type(None, byte_type, bytes.len() as i32);
|
||||
let typ = context.new_array_type(None, byte_type, bytes.len() as u64);
|
||||
let elements: Vec<_> =
|
||||
bytes.iter()
|
||||
.map(|&byte| context.new_rvalue_from_int(byte_type, byte as i32))
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use rustc_target::abi::{self, Align, HasDataLayout, Primitive, Size, WrappingRan
|
|||
|
||||
use crate::base;
|
||||
use crate::context::CodegenCx;
|
||||
use crate::errors::InvalidMinimumAlignment;
|
||||
use crate::type_of::LayoutGccExt;
|
||||
|
||||
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
||||
|
|
@ -30,6 +31,21 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_global_alignment<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, gv: LValue<'gcc>, mut align: Align) {
|
||||
// The target may require greater alignment for globals than the type does.
|
||||
// Note: GCC and Clang also allow `__attribute__((aligned))` on variables,
|
||||
// which can force it to be smaller. Rust doesn't support this yet.
|
||||
if let Some(min) = cx.sess().target.min_global_align {
|
||||
match Align::from_bits(min) {
|
||||
Ok(min) => align = align.max(min),
|
||||
Err(err) => {
|
||||
cx.sess().emit_err(InvalidMinimumAlignment { err });
|
||||
}
|
||||
}
|
||||
}
|
||||
gv.set_alignment(align.bytes() as i32);
|
||||
}
|
||||
|
||||
impl<'gcc, 'tcx> StaticMethods for CodegenCx<'gcc, 'tcx> {
|
||||
fn static_addr_of(&self, cv: RValue<'gcc>, align: Align, kind: Option<&str>) -> RValue<'gcc> {
|
||||
// TODO(antoyo): implement a proper rvalue comparison in libgccjit instead of doing the
|
||||
|
|
@ -81,7 +97,7 @@ impl<'gcc, 'tcx> StaticMethods for CodegenCx<'gcc, 'tcx> {
|
|||
let ty = instance.ty(self.tcx, ty::ParamEnv::reveal_all());
|
||||
let gcc_type = self.layout_of(ty).gcc_type(self);
|
||||
|
||||
// TODO(antoyo): set alignment.
|
||||
set_global_alignment(self, global, self.align_of(ty));
|
||||
|
||||
let value = self.bitcast_if_needed(value, gcc_type);
|
||||
global.global_set_initializer_rvalue(value);
|
||||
|
|
|
|||
|
|
@ -221,3 +221,9 @@ pub(crate) struct UnwindingInlineAsm {
|
|||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(codegen_gcc_invalid_minimum_alignment)]
|
||||
pub(crate) struct InvalidMinimumAlignment {
|
||||
pub err: String,
|
||||
}
|
||||
|
|
|
|||
16
src/type_.rs
16
src/type_.rs
|
|
@ -1,5 +1,3 @@
|
|||
use std::convert::TryInto;
|
||||
|
||||
use gccjit::{RValue, Struct, Type};
|
||||
use rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods, TypeMembershipMethods};
|
||||
use rustc_codegen_ssa::common::TypeKind;
|
||||
|
|
@ -202,8 +200,9 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
|||
value.get_type()
|
||||
}
|
||||
|
||||
fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> {
|
||||
if let Some(struct_type) = ty.is_struct() {
|
||||
fn type_array(&self, ty: Type<'gcc>, len: u64) -> Type<'gcc> {
|
||||
// TODO: remove this as well?
|
||||
/*if let Some(struct_type) = ty.is_struct() {
|
||||
if struct_type.get_field_count() == 0 {
|
||||
// NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a
|
||||
// size of usize::MAX in test_binary_search, we workaround this by setting the size to
|
||||
|
|
@ -211,14 +210,7 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
|||
// FIXME(antoyo): fix gccjit API.
|
||||
len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: see note above. Some other test uses usize::MAX.
|
||||
if len == u64::MAX {
|
||||
len = 0;
|
||||
}
|
||||
|
||||
let len: i32 = len.try_into().expect("array len");
|
||||
}*/
|
||||
|
||||
self.context.new_array_type(None, ty, len)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use rustc_middle::bug;
|
|||
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
|
||||
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};
|
||||
use rustc_target::abi::{self, Abi, Align, F32, F64, FieldsShape, Int, Integer, Pointer, PointeeInfo, Size, TyAbiInterface, Variants};
|
||||
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
|
||||
|
||||
use crate::abi::{FnAbiGccExt, GccType};
|
||||
|
|
@ -50,6 +50,12 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> CodegenCx<'a, 'tcx> {
|
||||
pub fn align_of(&self, ty: Ty<'tcx>) -> Align {
|
||||
self.layout_of(ty).align.abi
|
||||
}
|
||||
}
|
||||
|
||||
fn uncached_gcc_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout<'tcx>, defer: &mut Option<(Struct<'gcc>, TyAndLayout<'tcx>)>) -> Type<'gcc> {
|
||||
match layout.abi {
|
||||
Abi::Scalar(_) => bug!("handled elsewhere"),
|
||||
|
|
|
|||
3
test.sh
3
test.sh
|
|
@ -225,6 +225,9 @@ rustc = "$HOME/.rustup/toolchains/$rust_toolchain-$TARGET_TRIPLE/bin/rustc"
|
|||
|
||||
[target.x86_64-unknown-linux-gnu]
|
||||
llvm-filecheck = "`which FileCheck-10 || which FileCheck-11 || which FileCheck-12 || which FileCheck-13 || which FileCheck-14`"
|
||||
|
||||
[llvm]
|
||||
download-ci-llvm = false
|
||||
EOF
|
||||
|
||||
rustc -V | cut -d' ' -f3 | tr -d '('
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue