Re:C as an intermediate language (2012)
by d33 on Saturday January 20, 2018 @03:42AM
(#16192639)
I heard that GCC supports more architectures than LLVM. Perhaps Rust having a C backend would make sense? On the other hand, I have no idea how tightly coupled to LLVM it is.
[ Parent
| on HN ]
The language itself isn't coupled to LLVM outside of some underspecified details around things like unsafe and the memory model, which will eventually be better-defined.
The compiler has historically been fairly strongly tied to LLVM. This is changing for several reasons as the compiler is refactored, which should enable alternative backends like directly generating C or even plugging directly into GCC.
There is also an LLVM backend for generating C, at various levels of maintenance, that might be made to work.
A very long term project could be to eventually make the Rust compiler full Rust based.
However that would not make much sense from engineering point of view, too many years of optimization algorithms, tooling and supported architectures have been spent into gcc and LLVM backends just to thrown them away in name of purity.
There actually is work going on in that direction. The Cretonne code generator is written in Rust, and designed to support WebAssembly. It would also work as a fast rustc backend for debug builds on the few platforms it supports.
Interesting, thanks for point it out.
Re:C as an intermediate language (2012)
by adrianN on Saturday January 20, 2018 @03:44AM
(#16192643)
LLVM is used for optimizations in Rust. LLVM is more than just a nice way to target multiple backends, it's a very sophisticated set of building blocks for compilers.
Rust has tried to not couple its design to LLVM
For awhile LLVM could target C
Re:C as an intermediate language (2012)
by cpeterso on Saturday January 20, 2018 @01:48PM
(#16194722)
There is some discussion of supporting Mozilla's experimental Cretonne compiler (initially designed to be a new Firefox wasm JIT) as an alternative backend for rustc. Cretonne could be handy for developers wanting faster compile times during development with the cost of less code optimization.
https://internals.rust-lang.org/t/possible-alternative-compi...