Skip to content

Commit 789dfd2

Browse files
committed
Auto merge of #15284 - HKalbasi:mir, r=HKalbasi
Enable cfg miri in analysis
2 parents 8e5f944 + 41b8b0b commit 789dfd2

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

crates/hir-ty/src/mir/eval/shim.rs

+11
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,17 @@ impl Evaluator<'_> {
380380
let id = from_bytes!(i64, id.get(self)?);
381381
self.exec_syscall(id, rest, destination, locals, span)
382382
}
383+
"sched_getaffinity" => {
384+
let [_pid, _set_size, set] = args else {
385+
return Err(MirEvalError::TypeError("libc::write args are not provided"));
386+
};
387+
let set = Address::from_bytes(set.get(self)?)?;
388+
// Only enable core 0 (we are single threaded anyway), which is bitset 0x0000001
389+
self.write_memory(set, &[1])?;
390+
// return 0 as success
391+
self.write_memory_using_ref(destination.addr, destination.size)?.fill(0);
392+
Ok(())
393+
}
383394
_ => not_supported!("unknown external function {as_str}"),
384395
}
385396
}

crates/project-model/src/rustc_cfg.rs

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ pub(crate) fn get(
2222
}
2323
}
2424

25+
// Add miri cfg, which is useful for mir eval in stdlib
26+
res.push(CfgFlag::Atom("miri".into()));
27+
2528
match get_rust_cfgs(cargo_toml, target, extra_env) {
2629
Ok(rustc_cfgs) => {
2730
tracing::debug!(

0 commit comments

Comments
 (0)