From 41b8b0b77d5f30ff63aa3c2fdf87e643ca9481e5 Mon Sep 17 00:00:00 2001 From: hkalbasi Date: Fri, 14 Jul 2023 22:59:46 +0330 Subject: [PATCH] Enable cfg miri in analysis --- crates/hir-ty/src/mir/eval/shim.rs | 11 +++++++++++ crates/project-model/src/rustc_cfg.rs | 3 +++ 2 files changed, 14 insertions(+) diff --git a/crates/hir-ty/src/mir/eval/shim.rs b/crates/hir-ty/src/mir/eval/shim.rs index 28a5e50a56..9ad6087cad 100644 --- a/crates/hir-ty/src/mir/eval/shim.rs +++ b/crates/hir-ty/src/mir/eval/shim.rs @@ -380,6 +380,17 @@ impl Evaluator<'_> { let id = from_bytes!(i64, id.get(self)?); self.exec_syscall(id, rest, destination, locals, span) } + "sched_getaffinity" => { + let [_pid, _set_size, set] = args else { + return Err(MirEvalError::TypeError("libc::write args are not provided")); + }; + let set = Address::from_bytes(set.get(self)?)?; + // Only enable core 0 (we are single threaded anyway), which is bitset 0x0000001 + self.write_memory(set, &[1])?; + // return 0 as success + self.write_memory_using_ref(destination.addr, destination.size)?.fill(0); + Ok(()) + } _ => not_supported!("unknown external function {as_str}"), } } diff --git a/crates/project-model/src/rustc_cfg.rs b/crates/project-model/src/rustc_cfg.rs index 7ec6948eff..8392718b22 100644 --- a/crates/project-model/src/rustc_cfg.rs +++ b/crates/project-model/src/rustc_cfg.rs @@ -22,6 +22,9 @@ pub(crate) fn get( } } + // Add miri cfg, which is useful for mir eval in stdlib + res.push(CfgFlag::Atom("miri".into())); + match get_rust_cfgs(cargo_toml, target, extra_env) { Ok(rustc_cfgs) => { tracing::debug!(