Need help?
<- Back

Comments (60)

  • lioeters
    > For the past 3 years, I have been working on compiling Rust to C. .. This is, by my count, the 14th attempt: cillyGotta 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.miraheze.org/wiki/Bootstrapping_Specif...Oh, but I see there's a C++ implementation of the Rust compiler. https://github.com/thepowersgang/mrustcAnyway, this part sounds useful too, that crustc can compile across network and devices.> You build a small C server on your Blorbo OS, run rustc on some normal platform like Linux, and let cilly talk over the wire.
  • taris2
    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.
  • levkk
    Very cool. At first, I thought it was yet another LLM-generated demo, but no: original work of art. Super cool. Transpiling into C does seem easier than LLVM IR, and letting GCC optimize seems like this might actually work.Excited to see the compiler implementation when it's out -- a lot to learn from.
  • ronsor
    > I put my left hand in a blender. The blender won. (Still have all my fingers, just some stitches). I will not elaborate further.What a shame. I would've read an article about this.
  • ahartmetz
    Wait, I thought LLVM had a C backend which could be used for the purpose of transpiling Rust to C? Turns out not for a long time, but now maybe again: https://discourse.llvm.org/t/re-ann-llvm-c-backend-still-abl...
  • Cadwhisker
    > The primary goal of this is support for old/obscure hardware with no LLVM/GCC support. There are still some systems out there that don't support Rust but support C.The landing page mentions Plan 9 as one of the systems.
  • layer8
    Finally we can rewrite all the Rust in C. ;)
  • db48x
    We should port it to Rust.
  • npalli
    Rewrite in C is the new Rewrite in Rust.
  • SpecialistK
    I wonder if this could be used in PPC Mac OS X, where LLVM isn't supported and most graphical applications need to use GCC 4 with Apple's SDK.
  • ivanjermakov
    > The primary goal of this is support for old/obscure hardware with no LLVM/GCC supportWouldn't it be easier to add old hardware support to LLVM/GCC instead? I adore the project scale and determination, but for this goal extending existing projects seems more logical than building a language translator.
  • groos
    As an ex C++ compiler developer, I heartily approve of this project. Kudos.
  • adithyassekhar
    I'll wait for rustcrustc
  • micheleeet
    Rust is finally memory safe enough to become C
  • Imustaskforhelp
    This could be used within https://bootstrappable.org/projects.html to make bootstrappability of rust incredibly much easier other than the previous route of OCaml and other things.I know some folks within the bootstrappable OS projects community are on Hackernews and I hope that they could take a look at this. I feel as if this project could drastically shrink down the efforts needed to get a working rust compiler in a bootstrappable manner.
  • Tiberium
    I wonder how the performance looks like, because this can be interesting even for non-porting reasons ;)
  • nxtfari
    this is really cool but it seems very unlikely that someone targeting an exotic system not supported by rust (mostly embedded and ancient mainframe targets) would be willing to trust a beta transpiler to not inject any bugs or leaks in the process of turning rust to c. nevertheless, very cool.
  • moezd
    Let Rust vs C battle commence with renewed haste!
  • fithisux
    Kudos.
  • linzhangrun
    Quite an interesting project, lol. I like the name `crustc` :)
  • casey2
    Not to be confused with crust [1] the dialect of rust B [2][3] is written in.[1] https://github.com/tsoding/crust [2] https://github.com/bext-lang/b [3] https://www.nokia.com/bell-labs/about/dennis-m-ritchie/kbman...
  • valentynkit
    [dead]
  • CurbStomper
    [dead]
  • unjuno
    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.
  • dangoodmanUT
    i believe the author is confusedthis is the wrong direction(jk i read the readme)