All Projects → thepowersgang → Mrustc

thepowersgang / Mrustc

Licence: mit
Alternative rust compiler (re-implementation)

Labels

Projects that are alternatives of or similar to Mrustc

Online Compiler
This is an online compiler that can compile and run C\C++ And Java Program. This online compiler is a part of my 5th semester project "RUET Online Judge" . Developed By Ashadullah Shawon
Stars: ✭ 71 (-94.38%)
Mutual labels:  compiler
Rubyx
RubyX compiles ruby to binary (in ruby), hoping to be that X times faster
Stars: ✭ 78 (-93.82%)
Mutual labels:  compiler
Typhon
Snakes on rbx-head. A Python implementation for the Rubinius VM
Stars: ✭ 82 (-93.51%)
Mutual labels:  compiler
Mini Interpreter
A Simple Scripting Language
Stars: ✭ 72 (-94.3%)
Mutual labels:  compiler
Yapypy
Yet another Python Python
Stars: ✭ 77 (-93.9%)
Mutual labels:  compiler
Fennel
Lua Lisp Language
Stars: ✭ 1,225 (-3.01%)
Mutual labels:  compiler
Jit Compiler
JIT compiler in Go
Stars: ✭ 70 (-94.46%)
Mutual labels:  compiler
Uniroll
Opinionated universal frontend bundler in browser
Stars: ✭ 84 (-93.35%)
Mutual labels:  compiler
Idiolisp
A statically typed functional programming language
Stars: ✭ 78 (-93.82%)
Mutual labels:  compiler
Spvgentwo
SpvGenTwo is a SPIR-V building and parsing library written in plain C++17 without any dependencies. No STL or other 3rd-Party library needed.
Stars: ✭ 74 (-94.14%)
Mutual labels:  compiler
Ts Transform Css Modules
Extract css class names from required css module files for TypeScript
Stars: ✭ 75 (-94.06%)
Mutual labels:  compiler
Delta
Programming language focused on performance and productivity
Stars: ✭ 77 (-93.9%)
Mutual labels:  compiler
Typenovel
A simple markup language to write novel with types.
Stars: ✭ 80 (-93.67%)
Mutual labels:  compiler
Lens
Language for Embeddable .NET Scripting
Stars: ✭ 71 (-94.38%)
Mutual labels:  compiler
Forkphorus
JavaScript compiler for Scratch 3, 2, and 1 projects.
Stars: ✭ 83 (-93.43%)
Mutual labels:  compiler
Akilang
A compiler for a simple language, built with Python and LLVM
Stars: ✭ 71 (-94.38%)
Mutual labels:  compiler
Tiger
Tiger Compiler from "Modern Compiler Implementation in ML" by Andrew W. Appel
Stars: ✭ 77 (-93.9%)
Mutual labels:  compiler
Decent Messup
Mess up js code in a different way
Stars: ✭ 84 (-93.35%)
Mutual labels:  compiler
Zig
General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
Stars: ✭ 11,555 (+814.89%)
Mutual labels:  compiler
Jsdoctest
Run jsdoc examples as doctests.
Stars: ✭ 80 (-93.67%)
Mutual labels:  compiler

Mutabah's Rust Compiler

In-progress alternative rust compiler. Capable of building a fully-working copy of rustc, but not yet suitable for everyday use.

Build Status: windows Build Status: Linux/OSX

Intro

This project is an attempt at creating a simple rust compiler in C++, with the ultimate goal of being a 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.

Progress

  • Supported Targets:
    • x86-64 linux (fully bootstrap tested)
    • (incomplete) x86 windows
    • x86-64 windows (runnable executables, no bootstrap yet)
  • Builds working copies of rustc and cargo from a release source tarball
    • Supports both rustc 1.19.0 and 1.29.0
  • rustc bootstrap tested and validated (1.19.0 validated once, 1.29.0 is repeatable)
    • See the script TestRustcBootstrap.sh for how this was done.

Getting Started

Dependencies

  • C++14-compatible compiler (tested with gcc 5.4 and gcc 6)
  • C11 compatible C compiler (for output, see above)
  • 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)

Linux

  • make RUSTCSRC - Downloads the rustc source tarball (1.29.0 by default)
  • make -f minicargo.mk - Builds mrustc and minicargo, then builds libstd, libtest, finally rustc and cargo
  • make -C run_rustc - Build libstd and a "hello, world" using the above-built rustc

BSD

Similar to Linux, but you might need to

  • specify the rustc default target explicitly
  • specify the compiler
  • use gmake to run GNU make

e.g. gmake CC=cc RUSTC_TARGET=x86_64-unknown-freebsd -f minicargo.mk

Windows

(Tested with VS2015)

  • 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)
    • NOTE: I am open to suggestions for how to automate that step
  • Open vsproject/mrustc.sln and build minicargo
  • Run vsproject/run_hello.cmd to build libstd and "hello, world", and run it
    • There are other similar scripts for building cargo and rustc. Cargo works, but rustc hasn't fully been tested (building LLVM on windows has been a challenge)

Building non-rustc code

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 by running make -f minicargo.mk LIBS, or on windows with build_std.cmd.

Next, run

  • minicargo -L <path_to_libstd> <crate_path> to build a cargo project.
  • or, mrustc -L <path_to_libstd> --out-dir <output_directory> <path_to_main.rs> to directly invoke mrustc.

For additional options, both programs have a --help option.

Diagnosing Issues and Reporting Bugs

Debugging

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 output/libcore.hir_dbg.txt. 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

Bug Reports

Please try to include the following when submitting a bug report:

  • What you're trying to build
  • Your host system version (e.g. Ubuntu 17.10)
  • C/C++ compiler version
  • Revision of the mrustc repo that you're running

Support and Discussion

For problems that don't warrant opening an issue, join the IRC channel - irc.freenode.net#mrustc

Current Features

  • Full compilation chain including HIR and MIR stages (outputting to C)
  • MIR optimisations (to take some load off the C compiler)
  • Optional exhaustive MIR validation (set the MRUSTC_FULL_VALIDATE environment variable)
  • Functional cargo clone (minicargo)
    • Includes build script support
  • Procedural macros (custom derive)
  • Custom target specifications
    • See docs/target.md

Plans

Short-term

  • Fix currently-failing tests (mostly in type inference)
  • Fix all known TODOs in MIR generation (still some possible leaks)

Medium-term

  • Propagate lifetime annotations so that MIR can include a borrow checker
  • Emit C code that is (more) human readable (uses names from the original source, reduced/no gotos)
  • Add alternate backends (e.g. LLVM IR, cretonne, ...)

Note: All progress is against the source of rustc 1.19.0 AND rustc 1.29.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].