One of the devs here, chipping in with some details.
The sameple code in the article very much runs on consumer GPUs - I can run it on my mobile GPU(RTX 4050) without any issues. Really, it should work on any Volta+ architecture on NVIDIA(that is what we tested).
And no, there is no extension for that - and that is exactly the thing we have developed. The hostcall layer allows the GPU to invoke more or less arbitrary CPU functions, and get data from them.
IO, Networking, timers, etc - all of that can be implemented by calling CPU helpers from the GPU. As long as you write a small bit of boilerplate code, you should be able to add hostcalls for more or less anything you can do on the CPU.
Sorry, the README was out of date. Those numbers are from the beginning of the year, and now they are:
| .NET Core tests | 1764 | 48 | 20 | 96.29% |
| C Core tests | 1712 | 71 | 8 | 95.59% |
I am not affiliated with `cg_gcc`, but I have contributed some tiny things here and there.
Currently, `cg_gcc` is within spitting distance of being able to bootstrap the compiler. There really are only 3(!) bugs that currently stop a stage 2 build.
I know for sure, because I found workarounds for them, and have a working stage 2 build. A stage 3 build requires a bit more RAM than I have, but, besides that, it is definitely possible.
Those 3 bugs are:
1. Lack of support for 128 bit SwitchInt terminators(Rust IR equivalent of switch). This is likely caused by an issue on the GCC side, since libgccjit rejects 128 bit labels provided by `cg_gcc`.
2. A semantic difference between Rust's `#[inline(always)]` and `__attribute__((always_inline)) `. In Rust `#[inline(always)]` is a hint and works on recursive functions, but the GCC equivalent is not a hint, but a gurante, and does not work on recursive function.
3. `cg_gcc` miscompiles the Rust compiler's interner code if level 3 optimzations are enabled. The Rust compiler interner is quite complex, and does a lot of fiddly unsafe things, so it is the most likely to break. The exact cause of this issue is hard to pin down, but it can be worked around(by setting a lower opt level).
If you work around those issues, `cg_gcc` is able to successfully build the Rust compiler, at least on `x86_64 Linux`. Going from that to other architectures will still take time, but it is not as far away as some might think.
The linked article was mostly meant for people already lossely familiar with the project, but it seems it escaped its intended audience.
I do have a whole bunch of articles about the project on my website, going trough the entire journey of the project, from its start as a Rust to .NET compiler, to the current state.
I should have probably linked the previous articles in this one - I'll add that to my website. I'll also look into adding some more context to the articles next time.
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.
I have workarounds for all "simple" cases of UB in C(this is partially what the talk is about). The test code is running with `-fsantize=undefined`, and triggers no UB checks.
There are also escape hatches for strict aliasing in the C standard - mainly using memcpy for all memory operations.
Since signed multiplication is bitwise-equivalent to unsigned multiplication, I use unsigned multiplication to emulate UB-free signed multiplication. The signed variant of this overflow check is a bit harder to read because of that, but it still works just fine.
As for using `__builtin_popcountll` instead - you are right, my mistake. Thanks for pointing that out :).
I did not use the word "unsigned" before long long for the sake of readability - I know that repeating a word so many times can make it harder to parse for some folk. The project itself uses the correct types in the code, I was just kind of loose with the language in the article itself. My bad, I'll fix that and be a bit more accurate.
The sameple code in the article very much runs on consumer GPUs - I can run it on my mobile GPU(RTX 4050) without any issues. Really, it should work on any Volta+ architecture on NVIDIA(that is what we tested).
And no, there is no extension for that - and that is exactly the thing we have developed. The hostcall layer allows the GPU to invoke more or less arbitrary CPU functions, and get data from them.
IO, Networking, timers, etc - all of that can be implemented by calling CPU helpers from the GPU. As long as you write a small bit of boilerplate code, you should be able to add hostcalls for more or less anything you can do on the CPU.