Crustc, a Rust compiler created by translating the stock rustc 1.98.0-nightly compiler into C, has been published. The resulting compiler contains 46 million lines of C code, which can be compiled using GCC and the make utility. The compiler, built this way, successfully passes compilation tests for Rust code, such as the standard Rust libraries.
This project demonstrates the capabilities of the cilly compiler, which is currently in development and allows for translating Rust projects into C. The goal of this translation is to enable the compilation of code originally written in Rust in system environments and on architectures not supported by the rustc compiler. The output code is ANSI C (C89), potentially enabling projects to be compiled on legacy systems not supported by LLVM and GCC but for which an ANSI C compiler is available. The cilly compiler is not yet publicly available and will be published once it is ready for widespread testing. The project has been in the hands of a single enthusiast for three years.
Cilly is implemented as a backend for rustc, translating Rust's internal representation into C source code. A unique feature of cilly is that each translation is performed with a specific platform and target C compiler in mind. During the verification phase, cilly profiles the target C compiler using tests based on building a set of mini-programs that evaluate support for specific features (for example, _Thread_local) and determine platform specifics such as type sizes, memory data alignment, and structure layout.
Source: opennet.ru
