Skip to content

Commit 5c12305

Browse files
committed
Add description of the .NET backend project
1 parent b9efc93 commit 5c12305

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

posts/2024-11-01-gsoc-2024-results.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,17 @@ TODO
131131
- Mentor: [Jack Huey](https://github.com/jackh726)
132132
- [Final report](https://fractalfir.github.io/generated_html/rustc_codegen_clr_v0_2_0.html)
133133

134-
TODO
134+
As was already mentioned above, the Rust compiler can be used with various codegen backends. One of these is the [.NET backend][codegen-clr], which compiles Rust code to the Common Intermediate Language (CIL), which can then be executed by the .NET Common Language Runtime (CRL). This backend allows interoperability of Rust and .NET (e.g. C#) code, in an effort to bring these two ecosystems closer together.
135+
136+
At the start of this year, the .NET backend was already able to compile complex Rust programs, but it was still lacking certain crucial features. The goal of this GSoC project, implemented by none other than FractalFir, the author of the backend himself, was to extend the functionality of this backend in various areas. As a target goal, he set out to extend the backend so that it could be used to run tests using the `cargo test` command. Even though it might sound trivial, properly compiling and running the Rust test harness is non-trivial, as it makes use of complex features such as dynamic trait objects, atomics, panics, unwinding or multithreading. These features were tricky to implement in this codegen backend, especially because of large differences between how the .NET runtime works and the way LLVM usually does things.
137+
138+
However, this did not stop Fractal. He has been working on this project tirelessly, implementing new features, fixing various issues and learning more about the compiler's internals every new day. He has also been documenting his journey with (almost) daily [updates on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Rust.20to.20.2ENET.20compiler), which were fascinating to read. Once he has reached his original goal, he moved the goalpost up to another level and attempted to run the compiler's own test suite using the .NET backend. This helped him uncover additional edge cases and also led to a refactoring of the whole backend that resulted in significant performance improvements.
139+
140+
By the end of the GSoC project, the .NET backend was able to properly compile and run almost 95% of the standard library `core` and `std` test suite. That is an incredibly impressive number, since the suite contains thousands of tests, some of which are quite *arcane*. Fractal's pace has not slowed down even after the project has ended and he is still continuously improving the backend. Oh, and did we already mention that his backend can also emit *C* code, effectively acting as a *C* codegen backend?!
141+
142+
We thank Fractal for all his work on the .NET backend, as it was truly inspirational, and led to fruitful discussions that were relevant also to other codegen backends. Fractal's next goal is to get his backend upstreamed and create an official .NET compilation target, which could open up the doors to Rust becoming a first-class citizen in the .NET ecosystem.
143+
144+
[codegen-clr]: https://github.com/FractalFir/rustc_codegen_clr
135145

136146
### Sandboxed and Deterministic Proc Macro using Wasm
137147

0 commit comments

Comments
 (0)