GCC Rust status

As of today there is only one outstanding ticket for us to reach the goal of basic compilation of rust. The compiler currently the following building blocks in place:

  • Lexer
  • Parser
  • Static Analysis Pass structure
  • Abstracted GCC backend to GIMPLE reused from GCCGO which will need amendments over time

The first milestone is compile primitives: variable declarations, functions, conditionals, structures and loops. As these build up a base of primitives in the compiler than we can work from. The outstanding piece for the milestone is loops support minus enumerators and iterators.

There are many gaps in the first milestone. The type interference pass at the moment is quite naive. It tries to match up types and doesn’t take into account polymorphism. We also don’t do anything with the mut keyword at the moment, such that everything is mutable. Structs such this as can be declared but there are bugs here in terms of the omitting initial values.

struct Foo {
    one: i32,
    two: i32,
}
let struct_test = Foo { one: 1, two: 2 };

With the AST from the parser we are able to create a well defined structure for our static analysis passes using the Visitor Pattern. Although this makes the code work like a state machine, it has actually has made the code very reusable which is fantastic. I am excited to see how we will be able to abstract reusable parts of static analysis passes into base classes over time.

I see the compiler breaking down into several focused phases of development to get to the end goal. I would like to hear feed back on this.

  • Current phase – Basic single file compilation – Loops, conditionals, functions and structs
  • Polymorphism – Impl Blocks, Traits, Templates, macros
  • Multi-file compilation and Boxing/Borrowing, Lambda’s enumerations and iterators
  • Decouple our front-end into a separate project + Standard library integration and reusing the official test suite.
  • Rebasing against GCC and Merge upstream

For the maintainability of compiler we need to decouple our front-end code from GCC. Such that keeping the front-end up to date is not tied to changing GCC but updating the front-end project. If we achieve this goal there are a lot of interesting projects which are possible from this.

Leave a Reply

Your email address will not be published. Required fields are marked *