In-progress alternative rust compiler. Capable of building a fully-working copy of rustc, but not suitable for everyday use (due to terrible error messages).
This project is a "simple" rust compiler written in C++ that is able to bootstrap a "recent" rustc, but may eventually become a full separate re-implementation.
mrustc's primary goal is bootstrapping
rustc, and as such it tends to assume that the code it's compiling is valid (and any errors in the generated code are mrustc bugs). Code generation is done by emitting a high-level assembly (currently very ugly C, but LLVM/cretone/GIMPLE/... could work) and getting an external tool (i.e.
gcc) to do the heavy-lifting of optimising and machine code generation.
cargofrom a release source tarball
rustcbootstrap tested and validated (1.19.0 isn't fully repeatable, but later versions are)
TestRustcBootstrap.shfor how this was done.
make(for the mrustc makefiles)
patch(For doing minor edits to the rustc source)
libz-dev(used to reduce size of bytecode files, linux only - windows uses vcpkg to download it)
curl(for downloading the rust source, linux only)
cmake(at least 3.4.3, required for building llvm in rustc)
make RUSTCSRC- Downloads the rustc source tarball (1.29.0 by default)
make -f minicargo.mk- Builds
minicargo, then builds
make -C run_rustc- Build
libstdand a "hello, world" using the above-built rustc
Similar to Linux, but you might need to
gmaketo run GNU make
gmake CC=cc RUSTC_TARGET=x86_64-unknown-freebsd -f minicargo.mk
(Tested with VS2015)
rustc-1.29.0-src.tar.gzto the repository root (such that the
rustc-1.29.0-srcdirectory is present)
vsproject/mrustc.slnand build minicargo
vsproject/run_hello.cmdto build libstd and "hello, world", and run it
To build your own code with mrustc, first you need to build at least libcore (and probably the full standard library).
This can be done on Linux or macOS by running
make -f minicargo.mk LIBS, or on windows with
minicargo -L <path_to_libstd> <crate_path>to build a cargo project.
mrustc -L <path_to_libstd> --out-dir <output_directory> <path_to_main.rs>to directly invoke mrustc.
For additional options, both programs have a
Both the makefiles and
minicargo write the compiler's stdout to a file in the output directory, e.g. when building
output/libcore.hir it'll save to
To get full debug output for a compilation run, set the environment variable
MRUSTC_DEBUG to a : separated list of the passes you want to debug
(pass names are printed in every log line). E.g.
MRUSTC_DEBUG=Expand:Parse make -f minicargo.mk
Please try to include the following when submitting a bug report:
For problems that don't warrant opening an issue (e.g. help in running the compiler), join the IRC channel -