Live data from Hacker News

crustc: entirety of `rustc`, translated to C

github.com

31–40 of 99 posts

Re: crustc: entirety of `rustc`, translated to C

#31
post #8

Have you tried Diverse Double-Compiling (DDC) to test if the official rust compiler has a backdoor? Use crustc to compile the rust source code, producing a new compiler. Then use this new compiler and the official rustc binary, both with deterministic flags, to compile the rust source code again. The two outputs should match bit for bit.

This reminds me of https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_Ref...

Reflections on Trusting TRust.

Re: crustc: entirety of `rustc`, translated to C

#33
post #8

Have you tried Diverse Double-Compiling (DDC) to test if the official rust compiler has a backdoor? Use crustc to compile the rust source code, producing a new compiler. Then use this new compiler and the official rustc binary, both with deterministic flags, to compile the rust source code again. The two outputs should match bit for bit.

Better than that, you can get a bootstrapped rust from the Guix project, which has bootstrapped its entire system from source code from only a tiny verifiable binary.

Re: crustc: entirety of `rustc`, translated to C

#35
post #8

Have you tried Diverse Double-Compiling (DDC) to test if the official rust compiler has a backdoor? Use crustc to compile the rust source code, producing a new compiler. Then use this new compiler and the official rustc binary, both with deterministic flags, to compile the rust source code again. The two outputs should match bit for bit.

This reminds me of https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_Ref...

The sole and entire purpose of Diverse Double-Compiling is addressing Thompson's Trusting Trust: https://dwheeler.com/trusting-trust/

Re: crustc: entirety of `rustc`, translated to C

#37
The most interesting part of this to me is not “Rust to C” by itself, but the fact that it widens the pool of people who can help debug portability problems.

There are relatively few people who understand Rust’s compiler internals, LLVM backends, and obscure target support deeply. But there are many engineers who understand C compilers, ABIs, linkers, makefiles, cross-compilation, old operating systems, and weird platform-specific compiler behavior.

If Rust can be lowered into target-specific C, then some problems stop being exclusively “Rust compiler problems” and also become C toolchain problems. That means more people can inspect the generated C, build failures, linker errors, ABI mismatches, and compiler-specific behavior.

C is obviously not a magic portability layer. ABI details, integer widths, alignment, TLS, aliasing, and undefined behavior still matter. But as an ecosystem boundary, C gives many more engineers a way to participate in debugging and porting work.

I think that social/maintenance aspect may be more important than the language translation itself.

Re: crustc: entirety of `rustc`, translated to C

#39
post #7

> For the past 3 years, I have been working on compiling Rust to C. .. This is, by my count, the 14th attempt: cilly Gotta respect the dedication to a niche interest. > The primary goal of this is support for old/obscure hardware with no LLVM/GCC support. I remember reading about the bootstrapping question, how it typically requires a Rust compiler to build the Rust compiler from source. https://bootstrapping.mirahez…

So the author made a Rust to C transpiler and immediately used it to transpile... the Rust compiler. I love it.

It makes sense as a porting tool, if you need to port the Rust compiler to some target that has a C compiler.

But it doesn't mean rustc generates code for that target, only that you can run it there. You'd still have to teach LLVM about the target. Although that might already have been done.

It's not that useful for retro computers because the Rust compiler needs too much memory for most machines of the 32-bit era.

Re: crustc: entirety of `rustc`, translated to C

#40
post #37

The most interesting part of this to me is not “Rust to C” by itself, but the fact that it widens the pool of people who can help debug portability problems. There are relatively few people who understand Rust’s compiler internals, LLVM backends, and obscure target support deeply. But there are many engineers who understand C compilers, ABIs, linkers, makefiles, cross-compilation, old operating systems, and weird pla…

Guideline:

> Don't post generated text or AI-edited text. HN is for conversation between humans.

Post reply on HN