Skip to content

Commit 4045bf9

Browse files
bjorn3nagisa
authored andcommitted
Support running on miri
1 parent 8b9c70d commit 4045bf9

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

psm/build.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ fn find_assembly(
55
env: &str,
66
masm: bool,
77
) -> Option<(&'static str, bool)> {
8-
println!("cargo:rustc-check-cfg=cfg(switchable_stack,asm,link_asm)");
98
match (arch, endian, os, env) {
109
// The implementations for stack switching exist, but, officially, doing so without Fibers
1110
// is not supported in Windows. For x86_64 the implementation actually works locally,
@@ -58,6 +57,13 @@ fn find_assembly(
5857
fn main() {
5958
use std::env::var;
6059

60+
println!("cargo:rustc-check-cfg=cfg(switchable_stack,asm,link_asm)");
61+
62+
if var("CARGO_CFG_MIRI").is_ok() {
63+
// Miri doesn't have a stack limit and the inline asm wouldn't work on miri anyway.
64+
return;
65+
}
66+
6167
let arch = var("CARGO_CFG_TARGET_ARCH").unwrap();
6268
let env = var("CARGO_CFG_TARGET_ENV").unwrap();
6369
let os = var("CARGO_CFG_TARGET_OS").unwrap();

src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,20 @@ psm_stack_manipulation! {
268268
no {
269269
#[cfg(not(windows))]
270270
fn _grow(stack_size: usize, callback: &mut dyn FnMut()) {
271-
drop(stack_size);
271+
let _ = stack_size;
272272
callback();
273273
}
274274
}
275275
}
276276

277277
cfg_if! {
278-
if #[cfg(windows)] {
278+
if #[cfg(miri)] {
279+
// Miri doesn't have a stack limit
280+
#[inline(always)]
281+
unsafe fn guess_os_stack_limit() -> Option<usize> {
282+
None
283+
}
284+
} else if #[cfg(windows)] {
279285
use std::ptr;
280286
use std::io;
281287
use libc::c_void;

0 commit comments

Comments
 (0)