by blueflow · 4y ago · 0 comments
Compiling down to asm, lot of information is lost regarding memory layout etc, so it's not the best source for generating code.
edit: you also have mrustc as a Rust to C compiler outright.
Edit: Sorry I misremembered, they seem to compile C/C++ code to WASM then back to C: https://hacks.mozilla.org/2021/12/webassembly-and-back-again...
Although technically the plugins could be written in Rust.
I'd be curious to see the output! It'd be funny decompiling the rust compiler to C, then running it on another platform that way. (Though it would still be, for example, an x86 rust compiler running on arm).
That's an example of "lost in translation" as we don't know if the original source required ordering or not. x86 cannot express the weakest memory model supported by C.
I don't think this would work, unless the c file just contains inline assembly.
Not that the C will be much more readable than the dissassembly, but there's a chance less information will be lost.
How about formally verified SPARK code?
Are you aware of the scope of SPARK's assurances? You can't accidentally dereference a NULL pointer in verified SPARK code, for instance.