Live data from Hacker News

crustc: entirety of `rustc`, translated to C

github.com

81–90 of 99 posts

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

#81
post #78

Earlier quoted context omitted.

As far as I know, ISO c++ is no better than microsoft rust. It is said microsoft rust syntax is on the same brain damage complexity level than ISO c++. That, and I don't even talk about the technical cost of its runtime (not far from the toxicity of a jvm?)

What is Microsoft rust? I’ve never heard of such a thing. Or did I miss the joke?

I don't think there's a joke, this commenter seems to believe Rust is controlled by Microsoft

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

#82
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…

Guix uses mrustc for bootstrapping Rust, as required for compiler packages; it's a really impressive project and has worked well in that role for some time. This new project is interesting for other reasons though, because mrustc is targeted at the de fact "subset" of Rust in use by rustc at any given time. This looks like it could have broader applications, like compiling Rust programs for platforms not supported by…

> compiling Rust programs for platforms not supported by LLVM

For this, gcc-rs[1][2] is the most promising candidate.

[1] https://rust-gcc.github.io/

[2] https://github.com/Rust-GCC/gccrs

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

#84
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…

> The primary goal of this is support for old/obscure hardware with no LLVM/GCC support. If you're going to go to all this effort for an old target though, wouldn't the effort be better spent on making it an LLVM target? Then you'd get Rust and a bunch of other languages for free. But maybe there are required parts of the LLVM IR that make this undesirable for certain targets, maybe requiring specific hardware featur…

> WASM-as-IR .. (Is that a thing?)

Yes, actually I've heard of some projects compiling a language to Wasm, then using wasm2c to translate to C.

https://github.com/WebAssembly/wabt/blob/main/wasm2c/README....

The Zig project does something similar for their bootstrapping process with a custom wasm2c implementation with just the features they need.

https://github.com/ziglang/zig/blob/master/stage1/wasm2c.c

I get the feeling this is an underappreciated technique with more potential.

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

#86
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…

Guix uses mrustc for bootstrapping Rust, as required for compiler packages; it's a really impressive project and has worked well in that role for some time. This new project is interesting for other reasons though, because mrustc is targeted at the de fact "subset" of Rust in use by rustc at any given time. This looks like it could have broader applications, like compiling Rust programs for platforms not supported by…

I might have seen that Bootstrapping Rust article, how interesting. I've been curious about Guix for a while, one of these days I need to dive in and explore deeper. I really enjoyed their article on full-source bootstrap, it's relevant now more than ever.

Building from Source All the Way Down - https://guix.gnu.org/en/blog/2023/the-full-source-bootstrap-...

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

#87
post #82

Earlier quoted context omitted.

Guix uses mrustc for bootstrapping Rust, as required for compiler packages; it's a really impressive project and has worked well in that role for some time. This new project is interesting for other reasons though, because mrustc is targeted at the de fact "subset" of Rust in use by rustc at any given time. This looks like it could have broader applications, like compiling Rust programs for platforms not supported by…

> compiling Rust programs for platforms not supported by LLVM For this, gcc-rs[1][2] is the most promising candidate. [1] https://rust-gcc.github.io/ [2] https://github.com/Rust-GCC/gccrs

But what about platforms that even GCC doesn't support well? I'm thinking mostly retro stuff like 16-bit x86.

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

#88
post #85

If I understand this correctly, you could run this compiler on iPadOS (since it's plain C). But you cannot mark it's output executable, since that would require JIT entitlement.

Target WASM then

Sure, that works. Caveats:

1. Your frontend needs to support emitting WASM. Ok for Rust, not for every language out there.

2. 2x-4x performance overhead.

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

#89
post #81

Earlier quoted context omitted.

What is Microsoft rust? I’ve never heard of such a thing. Or did I miss the joke?

I don't think there's a joke, this commenter seems to believe Rust is controlled by Microsoft

Don't think I am alone to know that...

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

#90
post #82

Earlier quoted context omitted.

Guix uses mrustc for bootstrapping Rust, as required for compiler packages; it's a really impressive project and has worked well in that role for some time. This new project is interesting for other reasons though, because mrustc is targeted at the de fact "subset" of Rust in use by rustc at any given time. This looks like it could have broader applications, like compiling Rust programs for platforms not supported by…

> compiling Rust programs for platforms not supported by LLVM For this, gcc-rs[1][2] is the most promising candidate. [1] https://rust-gcc.github.io/ [2] https://github.com/Rust-GCC/gccrs

Gccrs is valuable for various reasons (bootstrapping, refining the spec, etc), but for the main purpose of "compiling to targets supported by gcc but not llvm", it's definitely not as promising as https://github.com/rust-lang/rustc_codegen_gcc. It's a rustc backend, at the same level as llvm or cranelift, it's much further along than gccrs (already available as a rustup component and can compile any rust code) and will not suffer from lagging behind rustc.

But OP has wider ambitions: the real niche targets are supported by neither gcc nor llvm. A rust-to-c transpiler that can adapt to weird C compilers should have a very wide reach.

Post reply on HN