Hawker News

Compiling Rust to readable C with Eurydice

lwn.net

79 pointsby peter_d_sherman15 comments

stabbles[3 comments hidden]
If it's readable C, this sounds great for a full source bootstrap of the rust compiler.
knxsnsn[2 comments hidden]
Why would it need to be readable to be applicable to bootstrapping?
stabbles[hidden]
It depends entirely on your trust model. If you just want to be able to compile a rust compiler on a new platform that only has a C compiler, you wouldn't care. If you worry about a Thompson-style trojan horse, then you want to be able to audit all sources in the bootstrap chain.

Some idealistic projects like live-bootstrap go a step further and don't even allow generated sources in the full source bootstrap chain, even if they are readable in principle, because the xz debacle showed that a configure script, which is also readable in principle, can contain a backdoor. In those projects you could probably still bootstrap Eurydice from sources, and then do the rust -> c translation of the rust compiler as an ordinary build step, before compiling it with a bootstrapped C compiler.

Neywiny[2 comments hidden]
I wish this covered more features specific to rust that make it more runtime safer not just compile time safer. I guess by the time it's IR it's the same but moving it back up to C would be nice to see. Like bounds checking.
Lvl999Noob[hidden]
I think those are covered. Any checks that Rust adds will be present in the IR (either coded in the original source or implied through rust semantics). Those checks would then get put in the compiled C output. The ideal output of Eurydice would be to have exactly the same semantics and safety as provided by Rust. Since their use case is to use Rust to code on platform without support for a rust compiler, it is a rather important goal to have too.
chias[5 comments hidden]
What an excellent choice of product name :D

"You're da C"

nfw2[4 comments hidden]
"you read da c"

Only know the pronunciation due to hadestown

nfw2[3 comments hidden]
Really more like "you're rid o(f) c" though, have you considered making it compile the other way
egeozcan[2 comments hidden]
Sorry but even threads about fringe mathematics are somewhat easier to decipher for me than this thread.

ELI5, anyone?

Twisol[hidden]
"Eurydice" is pronounced roughly like each of the ancestor posts. (It isn't "you-ree-dice".)
fithisux[4 comments hidden]
D and C++ would benefit from something like this.
pjmlp[3 comments hidden]
Why?

C++ started as a preprocessor that translated into C, nowadays all relevant C compilers are written in C++.

D has enough backeds already available.

uecker[2 comments hidden]
People still maintain old versions of GCC just to maintain a bootstrap path.

I also think it would be helpful to how have a useful intermediate result to look at. So I agree, having C++ to C compiler would be useful.

pjmlp[hidden]
Intermediate result is the compilation to Assembly source code, and C++ insights like tooling.

Those people should move on, there isn't a single relevant platform without at least C++98 compiler, and there are other ways to bootstrap compilers.

fnord77[hidden]
the circle is complete