This could be a very dumb question, but I'm wondering why the Rust compiler (written in Rust itself) require a C++ compiler.
I mean, a precompiled Rust compiler from the distribution should be enough, shouldn't it?
C++ has multiple compilers: for example, Clang, GCC, MinGW, Cfront, Intel C++ Compiler, Tiny C Compiler, LLVM, and more. For now, Rust's only compiler is LLVM-based, but a change is right around the corner, some language features used in high-performance code are only available with C++.
Invocation. Compilation begins when a user writes a Rust source program in text and invokes the rustc compiler on it. The work that the compiler needs to perform is defined by command-line options.
This means that the Rust compiler, rustc, can be used with the GCC backend, the backend being the code generator which supports more CPU architectures than LLVM, the usual Rust backend compiler, though there are limitations such as requiring a patched version of GCC. The alternative is to have a complete GCC toolchain.
rustc is the compiler for the Rust programming language, provided by the project itself. Compilers take your source code and produce binary code, either as a library or executable. Most Rust programmers don't invoke rustc directly, but instead do it through Cargo.
It is actually a reasonable question. The answer is that currently, the rust source includes a slightly patched version of LLVM, LLVM is written in C++, and that is not distributed in binary form. So you need a C++ compiler to build that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With