The Rust to .NET compiler turns 1 year old!
Exactly a year ago (August 10, 2023), I have created the very first commit in my Rust to .NET compiler!
To celebrate the occasion, I decided to share some stats about the progress I had made.
At the time of writing 93.9% of the core compiler tests pass. 3.95 % of tests fail(panic when they should not, or don't panic when they should), and 2.15% of tests did not complete. In alloc, 92.18 % of tests pass, 1.5 % fail, and 6.32 % did not complete. I did not yet test std due to a linker issue(2 different version of a static were present).
If a test is marked as "did not complete", then it terminated early due to some kind of issue. There are a lot of things that can cause a test to not finish, but the most common ones are missing intrinsics, detected compilation defects, and timeouts. Full runtime crashes are much rarer, but they do sometimes occur and are counted as "did not complete".
I felt like counting all of those more serious things as a separate "did not finish" category would be more useful than lumping them together with all other, "softer" failures.
Besides that, I had made some big refactors, which cut the memory usage of my linker by 7x, and should enable me to more easily implement new features.
FAQ:
Q: What is the intended purpose of this project?
A: The main goal is to allow people to use Rust crates as .NET libraries, reducing GC pauses, and improving performance. The project comes bundled together with an interop layer, which allows you to safely interact with C# code. More detailed explanation.
Q: Why are you working on a .NET related project? Doesn't Microsoft own .NET?
A: the .NET runtime is licensed under the permissive MIT license (one of the licenses the rust compiler uses). Yes, Microsoft continues to invest in .NET, but the runtime is managed by the .NET foundation.
Q: why .NET?
A. Simple: I already know .NET well, and it has support for pointers. I am a bit of a runtime / JIT / VM nerd, so this project is exciting for me. However, the project is designed in such a way that adding support for targeting other languages / VMs should be relatively easy. The project contains an experimental option to create C source code, instead of .NET assemblies. The entire C-related code is \~1K LOC, which should provide a rough guestimate on how hard supporting something else could be.
Q: How far from completion is the project:
A: Hard to say. The codegen is mostly feature complete (besides async), and the only thing preventing it from running more complex code are bugs. If I knew where / how many bugs there are, I would have fixed them already. So, providing any concrete timeline is difficult.
Q: benchmarks?
A: In terms of raw compute, Rust compiled for .NET does not differ much from C#. In more complex, memory-intensive scenarios, the project is not reliable enough to say anything with confidence. Right now, the project is at worst 3x slower than native Rust, and is usually around 1.5 - 2x slower than native Rust. The project currently does no optimizations.
Q: Can I contribute to the project?
A:Yes! I am currently accepting contributions, and I will try to help you if you want to contribute. Besides bigger contributions, you can help out by refactoring things or helping to find bugs. You can find a bug by building and testing some small crates, or by minimizing some of the problematic tests from this list.
Q: How else can I support the project?
A: If you are willing and able to, you can become my sponsor on Github. Things like starring the project also help a small bit.
This project is a part of Rust GSoC 2024. For the sake of transparency, I post daily updates about my work / progress on the Rust zulip. So, if you want to see those daily reports, you can look there.
If you have any more questions, feel free to ask me in the comments.