Rust to C compiler – 95.9% test pass rate, odd platforms
81–90 of 264 posts
Re: Rust to C compiler – 95.9% test pass rate, odd platforms
#82Why would I use a tool that doesn't pass all tests?
> This is an update on the progress I have made on my Rust to C compiler.
> There still are about 65 tests that need fixing, but they all seem to have pretty similar causes. So, fixing them should not be too difficult.
Re: Rust to C compiler – 95.9% test pass rate, odd platforms
#83At first I read it as C to rust compiler. What is the point of compiling rust to C?
Re: Rust to C compiler – 95.9% test pass rate, odd platforms
#84Earlier quoted context omitted.
Borrow checker, and more generally any type checkers, are essentially terminating programs ran during compilation process, thus safety guarantees given by them are ensured before the code is transformed into some target language.
Thats assuming lossless transpilation though
Re: Rust to C compiler – 95.9% test pass rate, odd platforms
#85Earlier quoted context omitted.
Not GP, but what is the point of touching Rust at all then?
To generate safer C?
Re: Rust to C compiler – 95.9% test pass rate, odd platforms
#86Earlier quoted context omitted.
I think there are probably C compilers for more platforms than there are rust compilers. So, if you want to compile your rust project on some obscure platform that doesn’t have a rust compiler for it yet, you could compile to C and then compile the resulting C code for that platform? Just a guess.
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…
Re: Rust to C compiler – 95.9% test pass rate, odd platforms
#87Earlier quoted context omitted.
What does this gain you that you can't already do with `extern "c"` functions from rust?
’Extern c’ still uses Rust. You want to skip Rust and call C from other languages directly.
Re: Rust to C compiler – 95.9% test pass rate, odd platforms
#88Re: Rust to C compiler – 95.9% test pass rate, odd platforms
#89Very cool. C to Rust would be fantastic.
What benefit would you envision from this?
2. You can do LTO between Rust and the C->Rust code so in theory you could get a smaller & faster executable.
3. In most cases it is the first step to a gradual rewrite in idiomatic Rust.
Re: Rust to C compiler – 95.9% test pass rate, odd platforms
#90Earlier quoted context omitted.
’Extern c’ still uses Rust. You want to skip Rust and call C from other languages directly.
Not GP, but what is the point of touching Rust at all then?
In verification, C has piles of static analyzers, dynamic analyzers, test generators (eg KLEE), code generators (eg for parsing), a prover (Frama-C), and a certified compiler. If using a subset of these, C code can be made more secure than Rust code with more effort.
There's also many tools for debugging and maintenance made for C. I can also obfuscate by swapping out processor ISA's because C supports all of them. On the business end, they may be cheaper with lower watts.
I also have more skilled people I can hire or contract to do any of the above. One source estimated 7 million C/C++ developers worldwide. There's also a ton of books, online articles, and example code for anything we need. Rust is very strong in that last area for a new language but C/C++ will maintain an advantage, esp for low-level programming.
These are the reasons I'd use Rust if I wanted C or C++ for deployment. Likewise, I wish there was still a top-notch C++ to C compiler to get the same benefits I described with C's tooling.