Merge branch 'master' into fixme
This commit is contained in:
commit
e73d0a3bca
@ -155,6 +155,9 @@ fn setup(ask_user: bool) {
|
||||
File::create(dir.join("Xargo.toml")).unwrap()
|
||||
.write_all(br#"
|
||||
[dependencies.std]
|
||||
default_features = false
|
||||
# We need the `panic_unwind` feature because we use the `unwind` panic strategy.
|
||||
# Using `abort` works for libstd, but then libtest will not compile.
|
||||
features = ["panic_unwind"]
|
||||
|
||||
[dependencies.test]
|
||||
|
21
src/lib.rs
21
src/lib.rs
@ -310,26 +310,9 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
|
||||
|
||||
const STATIC_KIND: Option<MiriMemoryKind> = Some(MiriMemoryKind::MutStatic);
|
||||
|
||||
#[inline(always)]
|
||||
fn enforce_validity(ecx: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool {
|
||||
if !ecx.machine.validate {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Some functions are whitelisted until we figure out how to fix them.
|
||||
// We walk up the stack a few frames to also cover their callees.
|
||||
const WHITELIST: &[(&str, &str)] = &[
|
||||
// Uses mem::uninitialized
|
||||
("std::sys::windows::mutex::Mutex::", ""),
|
||||
];
|
||||
for frame in ecx.stack().iter()
|
||||
.rev().take(3)
|
||||
{
|
||||
let name = frame.instance.to_string();
|
||||
if WHITELIST.iter().any(|(prefix, suffix)| name.starts_with(prefix) && name.ends_with(suffix)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
ecx.machine.validate
|
||||
}
|
||||
|
||||
/// Returns Ok() when the function was handled, fail otherwise
|
||||
|
@ -124,16 +124,33 @@ fn is_target_dir<P: Into<PathBuf>>(path: P) -> bool {
|
||||
path.metadata().map(|m| m.is_dir()).unwrap_or(false)
|
||||
}
|
||||
|
||||
fn for_all_targets<F: FnMut(String)>(sysroot: &Path, mut f: F) {
|
||||
fn target_has_std<P: Into<PathBuf>>(path: P) -> bool {
|
||||
let mut path = path.into();
|
||||
path.push("lib");
|
||||
std::fs::read_dir(path)
|
||||
.expect("invalid target")
|
||||
.map(|entry| entry.unwrap())
|
||||
.filter(|entry| entry.file_type().unwrap().is_file())
|
||||
.filter_map(|entry| entry.file_name().into_string().ok())
|
||||
.any(|file_name| file_name.starts_with("libstd") && file_name.ends_with(".rlib"))
|
||||
}
|
||||
|
||||
|
||||
fn for_all_targets<F: FnMut(String)>(sysroot: &Path, f: F) {
|
||||
let target_dir = sysroot.join("lib").join("rustlib");
|
||||
for entry in std::fs::read_dir(target_dir).expect("invalid sysroot") {
|
||||
let entry = entry.unwrap();
|
||||
if !is_target_dir(entry.path()) {
|
||||
continue;
|
||||
}
|
||||
let target = entry.file_name().into_string().unwrap();
|
||||
f(target);
|
||||
let mut targets = std::fs::read_dir(target_dir)
|
||||
.expect("invalid sysroot")
|
||||
.map(|entry| entry.unwrap())
|
||||
.filter(|entry| is_target_dir(entry.path()))
|
||||
.filter(|entry| target_has_std(entry.path()))
|
||||
.map(|entry| entry.file_name().into_string().unwrap())
|
||||
.peekable();
|
||||
|
||||
if targets.peek().is_none() {
|
||||
panic!("No valid targets found");
|
||||
}
|
||||
|
||||
targets.for_each(f);
|
||||
}
|
||||
|
||||
fn get_sysroot() -> PathBuf {
|
||||
|
Loading…
Reference in New Issue
Block a user