GCC Front-End For Rust

Alternative Rust Compiler for GCC

View the Project on GitHub

April 2023 Monthly report

Overview

Thanks again to Open Source Security, inc and Embecosm for their ongoing support for this project.

Milestone Progress

GCC 13.1 is on track to be released this week, and you might be a little surprised to see that gccrs will not be included in the release. This was done for multiple reasons, which you can read about in the blogpost we have published on the subject here. The reasoning boils down to “gccrs is not yet ready, nor is it useful for general users, and needs a little more time in the oven”. If you are still interested in trying out the compiler or hacking on it, we mention the alternatives in the blogpost.

Many contributors have submitted PRs this month, with over 50 contributions and three new contributors once again. Thank you all! The code submitted is extremely high quality, and fixes some very important issues (and sometimes, long-standing ones!) which you can read about in the various pull-requests linked below. We are also nearing the end of the review period for this year’s GSoC, meaning the results will be announced shortly - we are looking forward to working with the chosen students. Thank you again for your interest this year!

We are in the process of preparing a talk for EuroRust 2023, which we will be attending and where we hope to speak. We are looking forward to meeting with all of you once again!

Finally, we spent some time this month putting together new milestones to better reflect the upcoming work on the compiler. You can find a list of these milestones at the end of this report.

On the technical side of things, we are still progressing towards the compilation of the core Rust library. Philip has spent a lot of time on our type system once again, cleaning many HIR-related bugs which occured with iterators as well as other complex Rust traits. Arthur has kept working on the macro side of things, with more fixes regarding macro imports, exports, as well as derive macros. Pierre-Emmanuel Patry is doing some great work on our build system and procedural macro library, and we hope to soon expand our first user-defined macro!

Community call

We will have our next monthly community call on the 15th of May 2023. You can subscribe to our calendar to see when the next one will be held. The call is open to everyone, even if you would just like to sit-in and listen. You can also subscribe to our mailing-list or join our Zulip chat to be notified of upcoming events.

Completed Activities

Contributors this month

Overall Task Status

Category Last Month This Month Delta
TODO 218 219 +1
In Progress 43 49 +6
Completed 614 639 +25

Test Cases

TestCases Last Month This Month Delta
Passing 5728 7737 +2009
Failed - - -
XFAIL 40 53 +13
XPASS - - -

Bugs

Category Last Month This Month Delta
TODO 65 66 +1
In Progress 18 22 +4
Completed 287 304 +17

Milestones Progress

Note that the intrinsics milestone percentage on github is not representative: It shows a 73% completion rate, but does not take into account the tracking issues with dozens of unresolved items. Thus the percentage is computed using the sum of issues and tracked items done divided by the sums of issues and tracked items overall. Similarly, the Update GCC’s master branch milestone contains a tracking issue containing over 200 tasks. The percentage shown here takes this into account.

Milestone Last Week This Week Delta Start Date Completion Date Target
Data Structures 1 - Core 100% 100% - 30th Nov 2020 27th Jan 2021 29th Jan 2021
Control Flow 1 - Core 100% 100% - 28th Jan 2021 10th Feb 2021 26th Feb 2021
Data Structures 2 - Generics 100% 100% - 11th Feb 2021 14th May 2021 28th May 2021
Data Structures 3 - Traits 100% 100% - 20th May 2021 17th Sep 2021 27th Aug 2021
Control Flow 2 - Pattern Matching 100% 100% - 20th Sep 2021 9th Dec 2021 29th Nov 2021
Macros and cfg expansion 100% 100% - 1st Dec 2021 31st Mar 2022 28th Mar 2022
Imports and Visibility 100% 100% - 29th Mar 2022 13th Jul 2022 27th May 2022
Const Generics 100% 100% - 30th May 2022 10th Oct 2022 17th Oct 2022
Initial upstream patches 100% 100% - 10th Oct 2022 13th Nov 2022 13th Nov 2022
Upstream initial patchset 100% 100% - 13th Nov 2022 13th Dec 2022 19th Dec 2022
Update GCC’s master branch 100% 100% - 1st Jan 2023 21st Feb 2023 3rd Mar 2023
Final set of upstream patches 74% 96% +22% 16th Nov 2022 - 30th Apr 2023
Borrow Checking 1 0% 0% - TBD - 15th Aug 2023
AST Pipeline for libcore 1.49 0% 20% +20% 13th Apr 2023 - 1st Jun 2023
HIR Pipeline for libcore 1.49 0% 40% +40% 13th Apr 2023 - TBD
Procedural Macros 1 0% 45% +45% 13th Apr 2023 - 6th Aug 2023
GCC 13.2 Release 0% 0% - 13th Apr 2023 - 15th Jul 2023
GCC 14 Stage 3 0% 0% - TBD - 1st Nov 2023
Rustc Testsuite Prerequisistes 0% 0% - TBD - 1st Sep 2023
Intrinsics and builtins 18% 18% - 6th Sep 2022 - TBD
Const Generics 2 0% 0% - TBD - TBD
Rust-for-Linux compilation 0% 0% - TBD - TBD

Testing project

The testing project is on hold as we try and figure out some of the issues we’re running into with GitHub and our various automations around it.

Planned Activities

Detailed changelog

Builtin derive macros

While Pierre-Emmanuel Patry is working on support for custom procedural macros including `derive` macros, Arthur is spending some time on the implementation of builtin derive macros - there are only a handful of these macros (Clone, Copy, Debug, Default, Hash, {Partial}Eq and {Partial}Ord) but they are used very often in Rust code. The concept of deriving is well known to functional programmers, and in Rust it allows users to implement simple traits for their custom types without the extra boilerplate of creating an impl block.

A simple example we have been working on is the following:

pub trait Clone {
    fn clone(&self) -> Self;
}

pub trait Copy {}

impl Copy for i32 {}

impl<T> Clone for T
where
    T: Copy,
{
    fn clone(&self) -> Self {
        *self
    }
}

#[derive(Clone)]
struct S(i32, i32);

fn main() -> i32 {
    let a = S(15, 15);
    let b = a.clone();

    b.0 - b.1
}

Upon seeing the #[derive(Clone)] attribute, the compiler will generate an impl block for the structure S allowing us to call the clone method on it, as shown when initializing the b variable.

Here is a little comparison of the code generated by rustc and gccrs:

rustc with -Z unpretty=expanded:


#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use ::std::prelude::v1::*;
#[macro_use]
extern crate std;
pub trait Clone {
    fn clone(&self)
    -> Self;
}

pub trait Copy { }

impl Copy for i32 { }

impl <T> Clone for T where T: Copy {
    fn clone(&self) -> Self { *self }
}

struct S(i32, i32);
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for S {
    #[inline]
    fn clone(&self) -> S {
        match *self {
            S(ref __self_0_0, ref __self_0_1) =>
            S(::core::clone::Clone::clone(&(*__self_0_0)),
              ::core::clone::Clone::clone(&(*__self_0_1))),
        }
    }
}

fn main() -> i32 {
    let a = S(15, 15);
    let b = a.clone();

    b.0 - b.1
}

and gccrs with -frust-dump-all:

pub trait Clone{
    fn clone(&self) -> Self;

}

pub trait Copy{}

impl Copy for i32 {

}

impl Clone for T {
    fn clone(&self) -> Self {
        *self /* tail expr */

    }


}

impl Clone for S {
    fn clone(&self) -> Self {
        S(
            Clone::clone(
                &self.0,
            ),
            Clone::clone(
                &self.1,
            ),
        ) /* tail expr */

    }


}

struct S(i32, i32);

fn main() -> i32 {
    let a = S(
        15,
        15,
    );
    let b = ;
    b.0 - b.1 /* tail expr */

}

Since we are not yet able to link the core crate to the Rust projects we compile, we are not calling into ::core::clone::Clone::clone like rustc does - this is something that will be fixed as soon as we link against the core crate.

We still have a lot of work to do, especially regarding the handling of more complex builtin derive macros such as PartialOrd. Our future work will also include enhancing the user experience with these macros, as some “derive-specific” errors need to be emitted in order to not confuse users.