GCC Front-End For Rust

Alternative Rust Compiler for GCC

View the Project on GitHub

December 2023 Monthly report

Overview

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

Milestone Progress

All of the required “common part” patches were reviewed this month and subsequently pushed to GCC’s trunk branch. This allows us to move forward with updating upstream with the latest changes of our development repository. The commits are currently being tested once again one last time before a final push, which should happen this week. We will then resume work on the final parts of name resolution and handling of format_args!(), in order to support the required features for the GCC 14.1. release.

Progress on the compiler itself slowed down this month due to holidays. Both issues we had mentioned in our “Call for Contribution” section last month are being worked on, which is great. Thanks a lot for the interest in our project.

Jakub’s work on the borrow checker is continuing, with even more facts being emitted correctly and more invalid code being caught:


fn invalid_move() {
    // note that `A` is not `Copy`
    struct A {
        i: i32,
    }

    let a = A { i: 1 };
    let b = a; // a is moved here for the first time
    let c = a; //~ ERROR `a` moved here for the second time
}

fn valid_move() {
    let a = 1; // integers are `Copy`, so this is allowed
    let b = a;
    let c = a;
}

// runtime condition invalid move
fn test_move_conditional(b1: bool, b2:bool) {
    struct A {
        i: i32
    }

    let a = A { i: 1 }; // `A` cannot be copied

    if b1 {
        let b = a; // `a` might be moved here for the first time
    }
    if b2 {
        let c = a; // `a` might be moved here for the second time
    }
}

The work done by Jakub is also starting to enforce proper lifetime bounds:


fn lifetime_return_invalid<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 {
    y //~ ERROR 
}

fn lifetime_return_valid<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32
    where 'b: 'a
{
    y
}

And can handle complex expressions and borrow situations:


struct Reference<'a> {
    value: &'a i32,
}

impl<'a> Reference<'a> {
    fn new<'a>(value: &'a i32) -> Reference<'a> {
        Reference { value }
    }
}

fn mutable_borrow_while_immutable_borrowed_struct() {
    let x = 0;
    let y = Reference::new(&x);
    let z = &mut x; //~ ERROR
    let w = y;
}

We are looking forward to more progress on this side of the compiler, as it is an extremely important part of the Rust programming language - it is absolutely necessary that a borrow checker exists for Linux developers to start working in Rust using gccrs. Note that Jakub is currently finishing studying for his Master’s Degree and is looking for sponsorship to continue his work on the borrow checker. Please get in touch if you or your company would be interested in funding his work!

Finally, Pierre-Emmanuel, Philip and Arthur will all be present at FOSDEM 2024. We are excited to meet everyone in both the Rust and GCC rooms.

Community call

We will not have our monthly community call this month as we are preoccupied with upstreaming patches. 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.

Call for contribution

This is a new section for particularly easy or interesting issues we would like folks external to the project to contribute to. We are available for mentoring and guiding you on their resolution. This is a great way to start making your mark on a complex project such as this one and to learn a lot in the process!

When an instance of a struct is created with missing fields, the compiler should error out and report an error - indicating which fields are missing (https://doc.rust-lang.org/error_codes/E0063.html). This is currently unimplemented in gccrs, and working on this issue will enable you to look at multiple parts of the compiler such as error reporting and typechecking.

gccrs should produce an error when passing a function pointer argument with a different ABI than the one expected. It is a simple check to add into our typechecker, as we already encode all necessary ABI information in our HIR.

Check out our Contributing guidelines to get started on them or feel free to send us a message on Zulip or IRC!

Completed Activities

Contributors this month

Overall Task Status

Category Last Month This Month Delta
TODO 271 268 -3
In Progress 60 65 +5
Completed 777 784 +7

Test Cases

TestCases Last Month This Month Delta
Passing 8299 8347 +48
Failed - - -
XFAIL 69 69 -
XPASS - - -

Bugs

Category Last Month This Month Delta
TODO 102 99 -3
In Progress 33 37 +4
Completed 391 396 +5

Milestones Progress

Milestone Last Month This Month 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 100% 100% - 16th Nov 2022 1st May 2023 30th Apr 2023
Borrow Checking 1 0% 100% +100% TBD 8th Jan 2024 15th Aug 2023
AST Pipeline for libcore 1.49 78% 78% - 13th Apr 2023 - 1st Jul 2023
HIR Pipeline for libcore 1.49 69% 69% - 13th Apr 2023 - TBD
Procedural Macros 1 100% 100% - 13th Apr 2023 - 6th Aug 2023
GCC 13.2 Release 100% 100% - 13th Apr 2023 22nd Jul 2023 15th Jul 2023
GCC 14 Stage 3 100% 100% - 1st Sep 2023 20th Sep 2023 1st Nov 2023
core 1.49 functionality [AST] 4% 4% - 1st Jul 2023 - 1st Nov 2023
Rustc Testsuite Prerequisistes 0% 0% - TBD - 1st Feb 2024
Intrinsics and builtins 18% 18% - 6th Sep 2022 - TBD
Const Generics 2 0% 0% - TBD - TBD
Rust-for-Linux compilation 0% 0% - TBD - TBD
GCC 14.1 Release 0% 0% - TBD - 15th Apr 2024
Procedural Macros 2 57% 57% - TBD - TBD

Testing project

Testsuite Compiler Last month This month Success delta
rustc testsuite gccrs -fsyntax-only 92.7% 92.7% -
gccrs testsuite rustc stable 59.2% 59.2% -
rustc testsuite passing tests gccrs 14.0% 14.0% -
rustc testsuite (nostd) gccrs 27.5% 27.5% -
rustc testsuite (nocore) gccrs 3.8% 3.8% -
blake3 gccrs 25.0% 25.0% -
libcore gccrs 0% 0% -

Planned Activities

Risks

Risk Impact (1-3) Likelihood (0-10) Risk (I * L) Mitigation
Missing features for GCC 14.1 deadline 2 3 6 Start working on required features early

Detailed changelog