GCC Rust Weekly Status Report 30

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

Milestone Progress

Since Wednesday last week, I have been back from vacation, but we have still made significant progress in the current milestone thanks to the community working so hard. The pattern matching milestone includes cleaning up our code standards, such as getting rid of C++ Lambda’s, which created unnecessary complexity in handling error conditions where a simple for loop made was the simpler solution. All of this cleanup will bring gccrs closer to the GCC coding standards. The milestone also includes fixing known bugs required for the goal test case, but my work into closures is blocked pending some work into rust’s lang item system. Lang items are a way of mapping behaviour defined in libcore directly to the compiler, such as the built-in impl’s for primitive types or operator overloading. Closures rely on the higher-ranked trait bounds of the rust lang item of ‘fn’. This work on lang items is required for our goal test case to compile Blake3, so all of this work still feeds into our end goals of this milestone.

Regarding timing, I still have outstanding vacations to use, but the community has made a lot of progress in fixing bugs required for this milestone, so it is still hard to tell if I will make up the lost time from the previous milestone or not. However, I think it is likely that I might be one week out, making up just over half of the lost time from the traits milestone.

Hacktoberfest 2021

https://hacktoberfest.digitalocean.com/ we have marked out repository as part of the hacktoberfest community event feel free to join in, there are plenty of good first PR’s to tackle: https://github.com/Rust-GCC/gccrs/issues?q=is%3Aissue+is%3Aopen+label%3Agood-first-pr

Completed Activities

  • Bug fix missing code generation at coercion sites PR710
  • Add missing constant folding to array expressions PR725 PR748
  • Remove lambda’s as part of code standards cleanup PR727 PR728
  • Implement new Mutability enum for code cleanup PR729 PR738
  • Update PR template and contributor guidelines for DCO sign-off PR730
  • Add building blocks for Closure’s PR740
  • Implement base62 building blocks for V0 symbol mangling PR747

Contributors this week

Overall Task Status

CategoryLast WeekThis WeekDelta
TODO94108+14
In Progress915+6
Completed199213+14
GitHub Issues

Test Cases

CategoryLast WeekThis WeekDelta
Passing44684568+100
XFAIL2121
make check-rust

Bugs

CategoryLast WeekThis WeekDelta
TODO2122+1
In Progress48+4
Completed6972+3
GitHub Bugs

Milestones Progress

MilestoneLast WeekThis WeekDeltaStart DateCompletion DateTarget
Data Structures 1 – Core100%100%30th Nov 202027th Jan 202129th Jan 2021
Control Flow 1 – Core100%100%28th Jan 202110th Feb 202126th Feb 2021
Data Structures 2 – Generics100%100%11th Feb 202114th May 202128th May 2021
Data Structures 3 – Traits100%100%20th May 202117th Sept 202127th Aug 2021
Control Flow 2 – Pattern Matching7%20%+13%20th Sept 202129th Nov 2021
Macros and cfg expansion0%0%1st Dec 202128th Mar 2022
Imports and Visibility0%0%29th Mar 202227th May 2022
Const Generics0%0%30th May 202225th Jul 2022
Intrinsics0%0%6th Sept 202130th Sept 2022
GitHub Milestones

Risks

RiskImpact (1-3)Likelihood (0-10)Risk (I * L)Mitigation
Rust Language Changes3721Keep up to date with the Rust language on a regular basis
Going over target dates3515Maintain status reports and issue tracking to stakeholders

Planned Activities

Detailed changelog

Array Expression Const folding

Constant folding is an interesting thing in Rust which is similar in some regards to c++ constexpr. Constants must be folded as part of the type checking system since Array’s themselves have a constant expression of capacity for example. GCCRS has missing visitor’s for each of the possible constant folding cases. Here we have extended it to ArrayExpressions thanks to Rodrigo Valle.

const SIZE: usize = 14 + 2;
const TEST: [i32; SIZE] = [2; SIZE];

Coercion sites bug

When we have coercion sites such as passing arguments to a function, these are chances for missing conversions.

fn static_dispatch<T: Bar>(t: &T) {
    t.baz();
}

fn dynamic_dispatch(t: &dyn Bar) {
    t.baz();
}

fn main() {
    let a;
    a = &Foo(123);

    static_dispatch(a);
    dynamic_dispatch(a);
}

In this example ‘a’ is of type &Foo which is fine as an argument to static_dispatch but for dynamic dispatch, this needs to be converted into a vtable object. This is the same for the case when we have:

fn main() {
    let a;
    a = &Foo(123);

    let b: &dyn Bar = a;
}

The bug in the compiler is that this coercion_site was not being called for argument passing to implicitly convert the original argument.

Code cleanup

Thanks to all who are cleaning up the coding standards within the compiler this is including new enums such as Mutability which is much easier to use than using boolean flags:

Leave a Reply

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