News for hackers. Stuff that matters.
Re:Rust to C compiler – 95.9% test pass rate, odd platforms by Someone on Saturday April 12, 2025 @08:01AM (#43663662)
This project doesn’t have that as a goal. In fact, it doesn’t even have “Rust to C compiler” as a goal. https://github.com/FractalFir/rustc_codegen_clr:

“ The project aims to provide a way to easily use Rust libraries in .NET. It comes with a Rust/.NET interop layer, which allows you to easily interact with .NET code from Rust

[…]

While .NET is the main focus of my work, this project can also be used to compile Rust to C, by setting the C_MODE enviroment flag to 1.

This may seem like a strange and unrelated feature, but the project was written in such a way that this is not only possible, but relatively easy.”

It also doesn’t mention for which version of C it produces code. That may or may not hinder attempts to use this to run rust on obscure platforms.

Re:Rust to C compiler – 95.9% test pass rate, odd platforms by arka2147483647 on Saturday April 12, 2025 @08:47AM (#43663899)
The article mentions ANSI-C at places. So seems like the old c standard is targeted.
Re:Rust to C compiler – 95.9% test pass rate, odd platforms by FractalFir on Saturday April 12, 2025 @01:15PM (#43666248)
The README is slightly out of date, sorry. Supporting old platforms is one of the goals.

Truth be told, the support for C was at first added as a proff-of-concept that a Rust to C compiler is possible. But it worked surprisingly well, so I just decided to roll with it, and see where it takes me.

My policy in regards to C version is: I want to be as close to ANSI C as possible. So, I avoid modern C features as much as I can. I don't know if full compatibility is achievable, but I certainly hope so. Only time will tell.

Some simpler pieces of Rust work just fine with ANSI C compilers, but more complex code breaks(eg. due to unsupported intrinsics). If I will be able to solve that(+ some potential soundness issues) then I'll be able to use ANSI C.