# mrustc: a C++ reimplementation of the Rust compiler for bootstrapping rustc

> mrustc is an in-progress alternative Rust compiler written in C++ whose main purpose is bootstrapping rustc itself. It is not meant for everyday use, but it can build a working rustc and cargo from a source tarball.

**thepowersgang/mrustc** — Alternative rust compiler (re-implementation)

- Repository: https://github.com/thepowersgang/mrustc
- Stars: 2,533 · Forks: 142
- Language: C++
- License: MIT
- Published: 2026-09-28 · Updated: 2026-09-28 · Language: en
- Canonical page: https://hysenlabs.com/projects/thepowersgang-mrustc

## What mrustc solves and who it is for

The Rust compiler is normally built by an earlier version of itself. Breaking that cycle requires a separate implementation that can compile the Rust source of rustc without depending on an existing rustc binary. mrustc is that implementation, written in C++ and described in its README as an in-progress alternative Rust compiler. Its stated primary goal is bootstrapping rustc, and the README notes that it tends to assume the code it compiles is valid, treating errors in generated code as mrustc bugs rather than user errors.

The audience is narrow. The README says mrustc is capable of building a fully-working copy of rustc but is not suitable for everyday use because of terrible error messages. So the people who get value from it are those doing bootstrap work, compiler research, or porting Rust to environments where an existing rustc is unavailable. It is not a replacement for rustc in a normal development workflow, and the repository does not present it as one.

## How mrustc compiles Rust: HIR, MIR and C output

mrustc implements a full compilation chain including HIR and MIR stages, and emits C as its output. The README describes this as a high-level assembly, currently very ugly C, with the expectation that an external tool such as gcc does the heavy lifting of optimisation and machine code generation. That design keeps the backend simple: mrustc does not need its own code generator or register allocator, because it delegates that to the C compiler.

There are MIR optimisations to take some load off the C compiler, and an optional exhaustive MIR validation controlled by the MRUSTC_FULL_VALIDATE environment variable. The project also includes minicargo, described as a functional cargo clone with build script support, and it supports procedural macros via custom derive. Custom target specifications are documented in docs/target.md. The README lists plans for a MIR borrow checker and alternate backends such as LLVM IR or cretonne, which means the current C backend is a deliberate stage rather than a final architecture.

## Installing mrustc and building a hello world

The README lists dependencies for Linux and macOS: a C++14-compatible compiler, a C11-compatible C compiler for the output, GNU make, patch, libz-dev, curl, cmake (at least 3.4.3, needed for building LLVM inside rustc), pkg-config and python3. On Windows the README says to download and extract rustc-1.29.0-src.tar.gz into the repository root and open vsproject/mrustc.sln.

On Linux GNU and macOS, the first step downloads the rustc source tarball, 1.29.0 by default:

```bash
make RUSTCSRC
```

Then the minicargo makefile builds mrustc and minicargo, followed by libstd, libtest, rustc and cargo:

```bash
make -f minicargo.mk
```

After that, the run_rustc directory builds libstd and a hello world using the rustc that was just built:

```bash
make -C run_rustc
```

The README warns that the PARLEVEL environment variable controls parallel builds and can break at times, so outside of toying around it suggests PARLEVEL=1 or letting mrustc decide on its own:

```bash
PARLEVEL=1 make -f minicargo.mk
```

To build your own code rather than rustc, the README says you first need at least libcore and probably the full standard library, which on Linux or macOS is done with make -f minicargo.mk LIBS. Then minicargo can build a cargo project, or mrustc can be invoked directly:

```bash
minicargo -L <path_to_libstd> <crate_path>
mrustc -L <path_to_libstd> --out-dir <output_directory> <path_to_main.rs>
```

Both programs have a --help option for additional flags.

## Where mrustc breaks down or is the wrong tool

The README is unusually direct about limitations. Error messages are described as terrible, which is the reason it is not suitable for everyday use. That single fact disqualifies mrustc as a general-purpose compiler for application development: a compiler that assumes its input is valid gives poor feedback when the input is not.

Target support is also uneven. CI tests libstd on x86-64 Linux GNU and x86-64 Windows MSVC. The README says Windows executables run on Windows 10 but the bootstrap has never been fully tested there. macOS on x86-64 and arm64 is listed as a secondary target, and x86 Windows MSVC is described as incomplete. Older Rust versions have their own problem: 1.29 and older do not build on modern systems because of outdated openssl bindings. The README also notes that 1.19.0 is not fully repeatable, while later versions are. So the practical support matrix is narrower than the version list suggests, and anyone targeting Windows or macOS should treat the bootstrap as unproven.

## mrustc compared with gccrs and the standard rustc

gccrs is the other name that comes up in the same searches, and the difference in approach matters. gccrs is a Rust front end for GCC, so it plugs into GCC's existing optimisation and code generation pipeline. mrustc instead emits C and hands that C to an external compiler such as gcc, keeping its own backend minimal. Both avoid depending on rustc to build Rust code, but they sit at different layers: one integrates with a compiler framework, the other generates C as an intermediate step.

The comparison with the standard rustc is simpler. rustc is the reference implementation and the one the README expects mrustc to eventually reproduce, with the 1.90.0 bootstrap described as binary-equal to 1.91.1. mrustc's value is in being independent of that lineage, not in replacing it. If you want to compile Rust code for daily work, the README's own position is that mrustc is the wrong tool.

## Debugging mrustc builds and reporting bugs

When a build fails, the README points to two artefacts. Both the makefiles and minicargo write the compiler's stdout to a file in the output directory, for example output/libcore.hir_dbg.txt when building output/libcore.hir. Full debug output for a compilation run is enabled by setting MRUSTC_DEBUG to a colon-separated list of pass names, and pass names are printed in every log line:

```bash
MRUSTC_DEBUG=Expand:Parse make -f minicargo.mk
```

For bug reports, the README asks for what you are trying to build, your host system version, your C and C++ compiler versions, and the revision of the mrustc repository you are running. Support and discussion happen on the IRC channel irc.libera.chat#mrustc, which the README recommends for problems that do not warrant opening an issue, such as help running the compiler.

## Maintenance, upgrades and the MIT licence

The repository is not archived, and the last push was on 2026-09-28. The README describes the project as in progress, with short-term plans to fix currently-failing tests, mostly in type inference, and to fix known TODOs in MIR generation. Medium-term plans include a MIR borrow checker, more readable C output using names from the original source with fewer gotos, and alternate backends. Those plans are stated but not delivered, so anyone adopting mrustc should treat the current C backend as the stable surface.

Upgrade cost is dominated by the Rust version you target. The README says 1.90.0 is currently tested to fully bootstrap with a binary-equal 1.91.1, and lists 1.19.0, 1.29.0, 1.39.0, 1.54.0 and 1.74.0 as versions that might still bootstrap given the right environment. Each of those versions has a corresponding build script and patch file in the repository root, such as build-1.90.0.sh and rustc-1.90.0-src.patch, which indicates that moving between versions involves applying version-specific patches rather than a single supported path.

The project is licensed under MIT, with the licence file present as LICENCE-MIT. That is a permissive licence, but it does not resolve the licensing of the Rust source tarball that the build downloads, which carries its own terms. Anyone redistributing a bootstrapped rustc should check those separately; this is not legal advice.

## Conclusion

mrustc is for people who need to bootstrap rustc or cargo from source, or who want to study a C++ implementation of a Rust compiler. It is not for everyday Rust development, because the README itself says it is not suitable for that due to terrible error messages. Before relying on it, verify that your target is one of the tested ones, such as x86-64 Linux GNU, and that the rustc version you want is in the supported list, which includes 1.90.0, 1.74.0, 1.54.0, 1.39.0, 1.29.0 and 1.19.0.

## FAQ

### Why is Rust harder than C?

The README does not compare Rust with C. It only describes mrustc as an in-progress alternative Rust compiler written in C++ whose primary goal is bootstrapping rustc, and says it assumes the code it compiles is valid.

### Is Rust going to replace C?

The README does not discuss Rust replacing C. It states that mrustc is not suitable for everyday use because of terrible error messages, and that its purpose is bootstrapping rustc rather than general adoption.

### Was Rust written in C?

The README does not say what language Rust itself was written in. It says mrustc is a Rust compiler written in C++ that can bootstrap a recent rustc.

### Is Rust closer to C or C++?

The README makes no comparison between Rust and either C or C++. It describes mrustc's own output as high-level assembly, currently very ugly C, passed to an external tool such as gcc.

## Sources

- [Issues](https://github.com/thepowersgang/mrustc/issues)
- [License: MIT](https://github.com/thepowersgang/mrustc/blob/master/LICENSE)
- [README](https://github.com/thepowersgang/mrustc/blob/master/README.md)
- [thepowersgang/mrustc on GitHub](https://github.com/thepowersgang/mrustc)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/thepowersgang-mrustc
