{"id":13645914,"url":"https://github.com/thepowersgang/mrustc","last_synced_at":"2025-05-14T03:10:46.450Z","repository":{"id":23889439,"uuid":"27268808","full_name":"thepowersgang/mrustc","owner":"thepowersgang","description":"Alternative rust compiler (re-implementation)","archived":false,"fork":false,"pushed_at":"2025-05-05T12:15:33.000Z","size":16945,"stargazers_count":2290,"open_issues_count":26,"forks_count":117,"subscribers_count":44,"default_branch":"master","last_synced_at":"2025-05-05T13:30:05.342Z","etag":null,"topics":["compiler","rust-compiler","rust-language"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thepowersgang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-11-28T13:47:44.000Z","updated_at":"2025-05-05T12:15:39.000Z","dependencies_parsed_at":"2023-02-12T09:01:56.134Z","dependency_job_id":"297c66e4-adbf-4bc9-a65d-739020458da0","html_url":"https://github.com/thepowersgang/mrustc","commit_stats":{"total_commits":5625,"total_committers":53,"mean_commits":"106.13207547169812","dds":"0.027555555555555555","last_synced_commit":"dc1b6c238f9cd0ad1d12d26f44f8467d7fd4b9ae"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepowersgang%2Fmrustc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepowersgang%2Fmrustc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepowersgang%2Fmrustc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thepowersgang%2Fmrustc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thepowersgang","download_url":"https://codeload.github.com/thepowersgang/mrustc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254059512,"owners_count":22007769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","rust-compiler","rust-language"],"created_at":"2024-08-02T01:02:44.866Z","updated_at":"2025-05-14T03:10:41.441Z","avatar_url":"https://github.com/thepowersgang.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# Mutabah's Rust Compiler\n\n_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).\n\n[![Build Status: windows](https://ci.appveyor.com/api/projects/status/96y4ui20pl8xjm2h/branch/master?svg=true)](https://ci.appveyor.com/project/thepowersgang/mrustc/branch/master)\n[![C/C++ CI](https://github.com/thepowersgang/mrustc/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/thepowersgang/mrustc/actions/workflows/c-cpp.yml)\n\nIntro\n===\nThis project is a \"simple\" rust compiler written in C++ that is able to bootstrap a \"recent\" rustc.\n\nAs `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.\n\nProgress\n--------\n\n- Builds working copies of `rustc` and `cargo` from a release source tarball\n  - Supports (and can bootstrap) rustc 1.19.0, 1.29.0, 1.39.0, 1.54.0, and 1.74.0\n  - NOTE: Older versions (1.29 and older) don't build on modern systems, due to outdated openssl bindings\n- Supported Targets (CI tested for libstd):\n  - x86-64 linux GNU (should always work, fully bootstrap tested)\n  - x86-64 windows MSVC (Status: runnable executables on Windows 10, but bootstrap hasn't ever been fully tested)\n  - Secondary Targets\n    - x86-64 and arm64 macOS\n    - (incomplete) x86 windows MSVC\n- `rustc` bootstrap tested and validated (1.19.0 isn't fully repeatable, but later versions are)\n  - See the script `TestRustcBootstrap.sh` for how this was done.\n\n\nGetting Started\n===============\n\nYou can set the number of jobs (parallel builds) by setting the enviromment variable `PARLEVEL`, e.g. `PARLEVEL=$(nproc)` for CPU core count. This can and will break at times, as such outside of toying around, it's best to do `PARLEVEL=1` or let mrustc figure it out by itself.\n\nDependencies\n------------\n- C++14-compatible compiler (tested with gcc 5.4 and gcc 6, and MSVC 2015)\n- C11 compatible C compiler (for output, see above)\n- `GNU make` (for the mrustc makefiles)\n- `patch` (for doing minor edits to the rustc source)\n- `libz-dev` (used for reducing the size of bytecode files, linux only - windows uses vcpkg to download it)\n- `curl` (for downloading the rust source, linux only)\n- `cmake` (at least 3.4.3, required for building llvm in rustc)\n- `pkg-config` (required for finding crate build deps, i.e libssl)\n- `python3` (required for building llvm in rustc)\n\nLinux GNU and macOS\n-----\n- `make RUSTCSRC` - Downloads the rustc source tarball (1.29.0 by default)\n- `make -f minicargo.mk` - Builds `mrustc` and `minicargo`, then builds `libstd`, `libtest`, finally `rustc` and `cargo`\n- `make -C run_rustc` - Build `libstd` and a \"hello, world\" using the above-built rustc\n\nBSD\n---\nSimilar to Linux, but you might need to\n- specify the rustc default target explicitly\n- specify the compiler\n- use `gmake` to run GNU make\n- use `CC=gcc` or `CC=egcc` if `cc` is `clang`\n\ne.g. `gmake CC=gcc RUSTC_TARGET=x86_64-unknown-freebsd -f minicargo.mk`\n\nWindows\n--------\n(Tested with VS2015)\n- Download and extract `rustc-1.29.0-src.tar.gz` to the repository root (such that the `rustc-1.29.0-src` directory is present)\n  - NOTE: I am open to suggestions for how to automate that step\n- Open `vsproject/mrustc.sln` and build minicargo\n- Run `vsproject/run_hello.cmd` to build libstd and \"hello, world\", and run it\n  - There are other similar scripts for building cargo and rustc. Cargo works,\n    but rustc hasn't fully been tested (building LLVM on windows has been a challenge)\n\n\nBuilding non-rustc code\n=======================\n\nTo build your own code with mrustc, first you need to build at least libcore (and probably the full standard library).\nThis can be done on Linux or macOS by running `make -f minicargo.mk LIBS`, or on windows with `build_std.cmd`.\n\nNext, run\n- `minicargo -L \u003cpath_to_libstd\u003e \u003ccrate_path\u003e` to build a cargo project.\n- or, `mrustc -L \u003cpath_to_libstd\u003e --out-dir \u003coutput_directory\u003e \u003cpath_to_main.rs\u003e` to directly invoke mrustc.\n\nFor additional options, both programs have a `--help` option.\n\nDiagnosing Issues and Reporting Bugs\n====================================\n\nDebugging\n---------\nBoth the makefiles and `minicargo` write the compiler's stdout to a file in the output directory, e.g. when building\n`output/libcore.hir` it'll save to `output/libcore.hir_dbg.txt`.\nTo 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\n(pass names are printed in every log line). E.g. `MRUSTC_DEBUG=Expand:Parse make -f minicargo.mk`\n\nBug Reports\n-----------\nPlease try to include the following when submitting a bug report:\n- What you're trying to build\n- Your host system version (e.g. Ubuntu 17.10)\n- C/C++ compiler version\n- Revision of the mrustc repo that you're running\n\nSupport and Discussion\n----------------------\nFor problems that don't warrant opening an issue (e.g. help in running the compiler), join the IRC channel - `irc.libera.chat#mrustc`\n\n\nCurrent Features\n================\n- Full compilation chain including HIR and MIR stages (outputting to C)\n- MIR optimisations (to take some load off the C compiler)\n- Optional exhaustive MIR validation (set the `MRUSTC_FULL_VALIDATE` environment variable)\n- Functional cargo clone (minicargo)\n  - Includes build script support\n- Procedural macros (custom derive)\n- Custom target specifications\n  - See `docs/target.md`\n\nPlans\n=====\n\nShort-term\n----------\n- Fix currently-failing tests (mostly in type inference)\n- Fix all known TODOs in MIR generation (still some possible leaks)\n\nMedium-term\n-----------\n- Implement MIR borrow checker\n- Emit C code that is (more) human readable (uses names from the original source, reduced/no gotos)\n- Add alternate backends (e.g. LLVM IR, cretonne, ...)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthepowersgang%2Fmrustc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthepowersgang%2Fmrustc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthepowersgang%2Fmrustc/lists"}