flipperzero icon indicating copy to clipboard operation
flipperzero copied to clipboard

Get Miri functioning by reimplementing all of `sys` in Rust

Open loftyinclination opened this issue 1 month ago • 4 comments

This is the start of some work on attempting to get MIRI working. Since MIRI doesn't support FFI (outside of simple methods that don't allocate and that don't deal with pointers), this PR instead follows a similar path to the one put forward by Loom; namely, to define alternate versions of all of the problematic methods and types, and swap to use these types when running under the MIRI configuration.

Current status of work;

  • the alternate types and methods have all been defined, but are currently all method implementations have been left as TODOs.
  • The configuration for the project has been changed such that both cargo check and cargo miri run --example {gui,view_dispatcher} complete without any errors.
  • A few alternate implementations have been added for glue logic (such as for the global allocator and the panic handler), based on the examples laid out in the MIRI project's test directories.

Necessary remaining work;

  • reproducing the behaviour of the C implementations in the sys/miri_bindings types.
  • allowing for more of the examples to be run under this scope
  • adding some more examples to test some specifics.

Got started on this because I have been rebasing the gui-bindings PR onto main, and getting that back into working order. I might end up rebasing these changes on top of that local work (which I may also push up, if there's an interest), as that's really where I'd like to benefit from MIRI's analysis.

loftyinclination avatar Jan 04 '26 00:01 loftyinclination