miri icon indicating copy to clipboard operation
miri copied to clipboard

Add miri specific extern function for spawning a new thread in no_std projects

Open loftyinclination opened this issue 3 months ago • 9 comments

I'm attempting to run Miri in a no_std context, (testing some bindings against an FFI embedded thumbv7em-none-eabihf C project, for which we're attempting to get around the limitation of Miri working with FFI bindings by reimplementing the extern C methods in Rust), and have recently hit a roadblock. While we were able to get around the lack of std library implementation of panic handlers by following the example in some internal Miri tests, and the lack of alloc support by utilizing the native shims in miri_alloc and miri_dealloc, there's no equivalent example for thread::spawn.

I believe that it should be possible to create another extern function in https://github.com/rust-lang/miri/blob/master/tests/utils/miri_extern.rs, which would call into https://github.com/rust-lang/miri/blob/master/src/concurrency/thread.rs#L534, similar to how the windows and unix implementations handle things.

Would this be a sensible way to go? Would this patch be welcome?

loftyinclination avatar Jan 04 '26 20:01 loftyinclination