Supporting Rust is inevitable for platforms that want to remain viable for modern software releases
Supporting Rust is inevitable for platforms that want to remain viable for modern software releases
Posted Nov 22, 2024 18:22 UTC (Fri) by NYKevin (subscriber, #129325)In reply to: Supporting Rust is inevitable for platforms that want to remain viable for modern software releases by daroc
Parent article: NonStop discussion around adding Rust to Git
As for whether it's "dumb" enough - all I really want is something that is maintained. If they're going to continue maintaining mrustc, and explicitly support using it to transpile non-rustc code, then that would be fine regardless of whether it is "dumb" or "smart." But if, for whatever reason, mrustc turns out not to be suitable, then it seems plausible that it would be easier to write and maintain a "dumb" transpiler than a "smart" transpiler.
Posted Nov 24, 2024 2:38 UTC (Sun)
by gmatht (guest, #58961)
[Link] (2 responses)
The transpiled code wasn't exactly concise, but it worked. The transpiled code can make some assumptions about the target architecture so you might have to fiddle mrustc if you want to target something exotic. Also, mrustc seems to assume that you will compile the resulting code with -fwrapv (otherwise implementation defined signed integer overflow in Rust will become undefined in the resulting C).
I imagine the main limitation of mrustc is that it only supports up to Rust 1.54 at the moment. So, this excludes Rust-for-Linux which requires at least 1.78.0.
Posted Nov 24, 2024 15:43 UTC (Sun)
by ralfj (subscriber, #172874)
[Link] (1 responses)
I don't actually know what current Rust-to-C transpilers do in these cases. I assume they just generate C code with UB and hope for the best...
Posted Nov 26, 2024 5:18 UTC (Tue)
by NYKevin (subscriber, #129325)
[Link]
Yes, you lose provenance. No, that is not UB under any version of C that I've ever heard of. The standard explicitly provides that we are allowed to round-trip through at least char*, and intptr_t if it exists. If that breaks provenance, oh well, your implementation is just expected to deal with it anyway.
There probably is a performance cost to doing this. But IMHO it's acceptable if the alternative is "I can't run this code at all."
mrustc compatible with Rust 1.54
mrustc compatible with Rust 1.54
mrustc compatible with Rust 1.54