fixup! Add workaround for targets with too small a main stack size

This commit is contained in:
Mahmoud Al-Qudsi 2024-05-30 12:25:06 -05:00
parent a3e0d64e88
commit b495cffa50

View File

@ -192,9 +192,9 @@ fn has_small_stack(_: &Target) -> Result<bool, Box<dyn Error>> {
// build.rs is executed on the main thread, so we are getting the main thread's stack size. // build.rs is executed on the main thread, so we are getting the main thread's stack size.
// Modern macOS versions default to an 8 MiB main stack but legacy OS X have a 0.5 MiB one. // Modern macOS versions default to an 8 MiB main stack but legacy OS X have a 0.5 MiB one.
let stack_size = unsafe { pthread_get_stacksize_np(pthread_self()) }; let stack_size = unsafe { pthread_get_stacksize_np(pthread_self()) };
const TWO_MIB: usize = 2 * 1024 * 1024; const TWO_MIB: usize = 2 * 1024 * 1024 - 1;
match stack_size { match stack_size {
0..TWO_MIB => Ok(true), 0..=TWO_MIB => Ok(true),
_ => Ok(false), _ => Ok(false),
} }
} }