Merge pull request #401 from RalfJung/tests

run fullMIR tests in appveyor
This commit is contained in:
Oliver Schneider 2018-07-16 12:04:31 +02:00 committed by GitHub
commit f18fc27b6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 9 deletions

View File

@ -2,10 +2,10 @@ environment:
global: global:
PROJECT_NAME: miri PROJECT_NAME: miri
matrix: matrix:
- TARGET: i686-pc-windows-msvc
MSYS2_BITS: 32
- TARGET: x86_64-pc-windows-msvc - TARGET: x86_64-pc-windows-msvc
MSYS2_BITS: 64 MSYS2_BITS: 64
- TARGET: i686-pc-windows-msvc
MSYS2_BITS: 32
# branches to build # branches to build
branches: branches:
@ -35,6 +35,8 @@ test_script:
- set RUST_BACKTRACE=1 - set RUST_BACKTRACE=1
- cargo build --release - cargo build --release
- cargo test --release - cargo test --release
- set MIRI_SYSROOT=C:\Users\appveyor\.xargo\HOST
- cargo test --release
notifications: notifications:
- provider: Email - provider: Email

View File

@ -607,7 +607,7 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, '
} }
"_tlv_atexit" => { "_tlv_atexit" => {
return err!(Unimplemented("can't interpret with full mir for osx target".to_owned())); return err!(Unimplemented("Thread-local store is not fully supported on macOS".to_owned()));
}, },
// Stub out all the other pthread calls to just return 0 // Stub out all the other pthread calls to just return 0
@ -623,12 +623,53 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, '
} }
// Windows API subs // Windows API subs
"AddVectoredExceptionHandler" | "AddVectoredExceptionHandler" => {
"SetThreadStackGuarantee" => {
let usize = self.tcx.types.usize;
// any non zero value works for the stdlib. This is just used for stackoverflows anyway // any non zero value works for the stdlib. This is just used for stackoverflows anyway
self.write_scalar(dest, Scalar::from_u128(1), usize)?; self.write_scalar(dest, Scalar::from_u128(1), dest_ty)?;
}, },
"GetModuleHandleW" |
"GetProcAddress" |
"InitializeCriticalSection" |
"EnterCriticalSection" |
"TryEnterCriticalSection" |
"LeaveCriticalSection" |
"DeleteCriticalSection" |
"SetLastError" => {
// pretend these do not exist/nothing happened, by returning zero
self.write_scalar(dest, Scalar::from_u128(0), dest_ty)?;
},
"GetLastError" => {
// this is c::ERROR_CALL_NOT_IMPLEMENTED
self.write_scalar(dest, Scalar::from_u128(120), dest_ty)?;
},
// Windows TLS
"TlsAlloc" => {
// This just creates a key; Windows does not natively support TLS dtors.
// Figure out how large a TLS key actually is. This is c::DWORD.
let key_size = self.layout_of(dest_ty)?.size;
// Create key and return it
let key = self.memory.create_tls_key(None) as u128;
if key_size.bits() < 128 && key >= (1u128 << key_size.bits() as u128) {
return err!(OutOfTls);
}
self.write_scalar(dest, Scalar::from_u128(key), dest_ty)?;
}
"TlsGetValue" => {
let key = self.value_to_scalar(args[0])?.to_bytes()?;
let ptr = self.memory.load_tls(key)?;
self.write_ptr(dest, ptr, dest_ty)?;
}
"TlsSetValue" => {
let key = self.value_to_scalar(args[0])?.to_bytes()?;
let new_ptr = self.into_ptr(args[1].value)?;
self.memory.store_tls(key, new_ptr)?;
// Return success (1)
self.write_scalar(dest, Scalar::from_u128(1), dest_ty)?;
}
// We can't execute anything else // We can't execute anything else
_ => { _ => {

View File

@ -141,7 +141,12 @@ pub fn create_ecx<'a, 'mir: 'a, 'tcx: 'mir>(
main_id: DefId, main_id: DefId,
start_wrapper: Option<DefId>, start_wrapper: Option<DefId>,
) -> EvalResult<'tcx, (EvalContext<'a, 'mir, 'tcx, Evaluator<'tcx>>, Option<Pointer>)> { ) -> EvalResult<'tcx, (EvalContext<'a, 'mir, 'tcx, Evaluator<'tcx>>, Option<Pointer>)> {
let mut ecx = EvalContext::new(tcx.at(syntax::codemap::DUMMY_SP), ty::ParamEnv::reveal_all(), Default::default(), Default::default()); let mut ecx = EvalContext::new(
tcx.at(syntax::codemap::DUMMY_SP),
ty::ParamEnv::reveal_all(),
Default::default(),
MemoryData::new()
);
let main_instance = ty::Instance::mono(ecx.tcx.tcx, main_id); let main_instance = ty::Instance::mono(ecx.tcx.tcx, main_id);
let main_mir = ecx.load_mir(main_instance.def)?; let main_mir = ecx.load_mir(main_instance.def)?;
@ -338,7 +343,7 @@ pub struct TlsEntry<'tcx> {
dtor: Option<ty::Instance<'tcx>>, dtor: Option<ty::Instance<'tcx>>,
} }
#[derive(Clone, Default, PartialEq, Eq)] #[derive(Clone, PartialEq, Eq)]
pub struct MemoryData<'tcx> { pub struct MemoryData<'tcx> {
/// The Key to use for the next thread-local allocation. /// The Key to use for the next thread-local allocation.
next_thread_local: TlsKey, next_thread_local: TlsKey,
@ -355,6 +360,17 @@ pub struct MemoryData<'tcx> {
statics: HashMap<GlobalId<'tcx>, AllocId>, statics: HashMap<GlobalId<'tcx>, AllocId>,
} }
impl<'tcx> MemoryData<'tcx> {
fn new() -> Self {
MemoryData {
next_thread_local: 1, // start with 1 as we must not use 0 on Windows
thread_local: BTreeMap::new(),
locks: HashMap::new(),
statics: HashMap::new(),
}
}
}
impl<'tcx> Hash for MemoryData<'tcx> { impl<'tcx> Hash for MemoryData<'tcx> {
fn hash<H: Hasher>(&self, state: &mut H) { fn hash<H: Hasher>(&self, state: &mut H) {
let MemoryData { let MemoryData {

View File

@ -139,6 +139,7 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, '
None => self.memory.fetch_tls_dtor(None)?, None => self.memory.fetch_tls_dtor(None)?,
}; };
} }
// FIXME: On a windows target, call `unsafe extern "system" fn on_tls_callback`.
Ok(()) Ok(())
} }
} }