From 915695371ff79f7df437494790bcec378996adff Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Thu, 3 May 2018 21:57:50 +0100 Subject: [PATCH 1/3] Minor fix to get build working --- miri/bin/miri.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miri/bin/miri.rs b/miri/bin/miri.rs index 6ba86c81e0..5491762c33 100644 --- a/miri/bin/miri.rs +++ b/miri/bin/miri.rs @@ -111,7 +111,7 @@ fn after_analysis<'a, 'tcx>(state: &mut CompileState<'a, 'tcx>) { fn visit_item(&mut self, i: &'hir hir::Item) { if let hir::Item_::ItemFn(_, _, _, _, _, body_id) = i.node { if i.attrs.iter().any(|attr| { - attr.name().map_or(false, |n| n == "test") + attr.name() == "test" }) { let did = self.0.hir.body_owner_def_id(body_id); From 3d8c7a8dba7cab5d2d222cc08eaac648d6529b6a Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Thu, 3 May 2018 23:29:13 +0100 Subject: [PATCH 2/3] Fixed build for latest nightly --- miri/fn_call.rs | 1 - miri/lib.rs | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/miri/fn_call.rs b/miri/fn_call.rs index 51e5547de4..c763802bec 100644 --- a/miri/fn_call.rs +++ b/miri/fn_call.rs @@ -2,7 +2,6 @@ use rustc::ty::{self, Ty}; use rustc::ty::layout::{self, Align, LayoutOf}; use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX}; use rustc::mir; -use rustc_target::spec::abi::Abi; use rustc_data_structures::indexed_vec::Idx; use rustc_target::spec::abi::Abi; use syntax::attr; diff --git a/miri/lib.rs b/miri/lib.rs index 9b18888451..8359f0ad7a 100644 --- a/miri/lib.rs +++ b/miri/lib.rs @@ -11,9 +11,8 @@ extern crate log; // From rustc. #[macro_use] extern crate rustc; -extern crate rustc_mir; -extern crate rustc_target; extern crate rustc_data_structures; +extern crate rustc_mir; extern crate rustc_target; extern crate syntax; extern crate regex; From 6bc35f77cec4947dd9cb38e34dc6354745645d82 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 7 May 2018 10:38:13 +0200 Subject: [PATCH 3/3] Fix allocator api and temporarily disable validation_op --- miri/fn_call.rs | 22 +++++++++------------- miri/lib.rs | 4 +++- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/miri/fn_call.rs b/miri/fn_call.rs index c763802bec..c862238e88 100644 --- a/miri/fn_call.rs +++ b/miri/fn_call.rs @@ -627,7 +627,7 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, ' match &path[..] { // Allocators are magic. They have no MIR, even when the rest of libstd does. - "alloc::heap::::__rust_alloc" => { + "alloc::alloc::::__rust_alloc" => { let size = self.value_to_primval(args[0])?.to_u64()?; let align = self.value_to_primval(args[1])?.to_u64()?; if size == 0 { @@ -641,7 +641,7 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, ' Some(MemoryKind::Rust.into()))?; self.write_primval(dest, PrimVal::Ptr(ptr), dest_ty)?; } - "alloc::heap::::__rust_alloc_zeroed" => { + "alloc::alloc::::__rust_alloc_zeroed" => { let size = self.value_to_primval(args[0])?.to_u64()?; let align = self.value_to_primval(args[1])?.to_u64()?; if size == 0 { @@ -656,7 +656,7 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, ' self.memory.write_repeat(ptr.into(), 0, size)?; self.write_primval(dest, PrimVal::Ptr(ptr), dest_ty)?; } - "alloc::heap::::__rust_dealloc" => { + "alloc::alloc::::__rust_dealloc" => { let ptr = self.into_ptr(args[0].value)?.to_ptr()?; let old_size = self.value_to_primval(args[1])?.to_u64()?; let align = self.value_to_primval(args[2])?.to_u64()?; @@ -672,27 +672,23 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, ' MemoryKind::Rust.into(), )?; } - "alloc::heap::::__rust_realloc" => { + "alloc::alloc::::__rust_realloc" => { let ptr = self.into_ptr(args[0].value)?.to_ptr()?; let old_size = self.value_to_primval(args[1])?.to_u64()?; - let old_align = self.value_to_primval(args[2])?.to_u64()?; + let align = self.value_to_primval(args[2])?.to_u64()?; let new_size = self.value_to_primval(args[3])?.to_u64()?; - let new_align = self.value_to_primval(args[4])?.to_u64()?; if old_size == 0 || new_size == 0 { return err!(HeapAllocZeroBytes); } - if !old_align.is_power_of_two() { - return err!(HeapAllocNonPowerOfTwoAlignment(old_align)); - } - if !new_align.is_power_of_two() { - return err!(HeapAllocNonPowerOfTwoAlignment(new_align)); + if !align.is_power_of_two() { + return err!(HeapAllocNonPowerOfTwoAlignment(align)); } let new_ptr = self.memory.reallocate( ptr, old_size, - Align::from_bytes(old_align, old_align).unwrap(), + Align::from_bytes(align, align).unwrap(), new_size, - Align::from_bytes(new_align, new_align).unwrap(), + Align::from_bytes(align, align).unwrap(), MemoryKind::Rust.into(), )?; self.write_primval(dest, PrimVal::Ptr(new_ptr), dest_ty)?; diff --git a/miri/lib.rs b/miri/lib.rs index 8359f0ad7a..ca479e765c 100644 --- a/miri/lib.rs +++ b/miri/lib.rs @@ -448,6 +448,8 @@ impl<'mir, 'tcx: 'mir> Machine<'mir, 'tcx> for Evaluator<'tcx> { op: ::rustc::mir::ValidationOp, operand: &::rustc::mir::ValidationOperand<'tcx, ::rustc::mir::Place<'tcx>>, ) -> EvalResult<'tcx> { - ecx.validation_op(op, operand) + // FIXME: prevent this from ICEing + //ecx.validation_op(op, operand) + Ok(()) } }