GCC Rust Weekly Status Report 24

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

Milestone Progress

We are getting closer to the end of this milestone and last week saw my long living branch finally getting merged. This branch has added the relevant code to support type bounds, which is the last building block to implement the remaining tasks of the traits milestone. This means future work to complete traits should be smaller and easier to review. However, two outstanding tasks carry some risk in making my deadline go over: trait objects (dyn keyword), which implements vtable lookups and autodref to resolve paths fully.

BCS and Rust London

I will be attending and speaking at a hybrid conference on the 25th August here is the relevant link if you wish to check in on this.

Monthly Community Call

We had our Monthly community call please find our meeting notes over on: https://github.com/Rust-GCC/Reporting/blob/main/2021-08-06-community-call.md

Detailed changelog

Type Bounds

Last week the goal was to finally merge last big branch which adds the initial type-bounds support such as:

trait Foo {
    fn default() -> i32;
    fn get(self) -> i32;
}

struct Bar(i32);
impl Foo for Bar {
    fn default() -> i32 {
        123
    }

    fn get(self) -> i32 {
        self.0
    }
}

fn type_bound_test<T: Foo>(a: T) -> i32 {
    T::default() + a.get()
}

fn main() {
    let a;
    a = Bar(456);

    let b;
    b = type_bound_test(a);
}

This includes checks for when a type does not support the type bound for example:

trait Foo {
    fn default() -> i32;
}

trait Bar {
    fn not_default() -> i32;
}

trait Baz {
    fn cake() -> i32;
}

struct Test(i32);

impl Foo for Test {
    fn default() -> i32 {
        1234
    }
}

fn type_bound_test<T: Foo + Bar + Baz>() -> i32 {
    T::default()
}

fn main() {
    let a = type_bound_test::<Test>();
}

Will return:

test.rs:26:31: error: bounds not satisfied for Test ‘Bar, Baz’ is not satisfied
   21 | fn type_bound_test<T: Foo + Bar + Baz>() -> i32 {
      |                             ~     ~
......
   26 |     let a = type_bound_test::<Test>();
      |                               ^

You watch some of the development process on my youtube channel for this patch:

Fix ICE when using f64 on 32 bit systems

Thanks to our new contributor Michael Karcher who has fixed an bug with how 64bit floats were handled on 32bit systems. GCC was automatically changing our f64 into float:80 which is the case when we need an excess precision type. The issue was that we were missing a gcc conversion for the new tree so the types are updated correctly.

This means we now have fully passing builds on Marks build farm:

  • debian arm64
  • fedora ppc64le
  • fedora ppc64
  • debian i386
  • fedora s390x

Thanks to John Paul Adrian Glaubitz who has also completed the manual testing on:

  • debian hppa
  • debian m68k
  • debian s390x

As part of GitHub automation we do not accept any PR which causes any regression to ubuntu-x86_64.

Fix parser bug when using null terminator in strings

With our recent examples showing HelloWorld working via printf, we noticed that the null terminator was not being respected when added to strings, this turned out to be a bug in the parser so we have added a new test case to catch this:

/* { dg-output "bar foo baz foobar\n" } */
extern "C"
{Last Week
  fn printf(s: *const i8, ...);
  fn memchr(s: *const i8, c: u8, n: usize) -> *const i8;
}

pub fn main ()
{
  let f = "%s %s %s %s\n\0";
  let s = "bar\0\
           foo\
           \x00\
           baz\u{0000}\
           foobar\0";
  let cf = f as *const str as *const i8;
  let cs = s as *const str as *const i8;
  unsafe
    {
      let cs2 = memchr (cs, b'f', 5);
      let cs3 = memchr (cs2, b'b', 5);
      let cs4 = memchr (cs3, b'f', 5);
      printf (cf, cs, cs2, cs3, cs4);
    }
}

Completed Activities

  • Typebounds support PR611 PR612
  • Fix lexer bug with nul terminated strings PR615
  • Union support PR601 PR602
  • Handle unsafe in liveness analysis PR604
  • Fix floating point issues with f64 on 32 bit systems PR614
  • Building blocks for multiple file support PR608 PR605
  • Fix ICE in parser when identifier is nullptr PR606
  • Cleanup PR612 PR610 PR607

Contributors this week

Excluding merges, 5 authors have pushed 25 commits to master and 26 commits to all branches. On master, 56 files have changed and there have been 1,799 additions and 775 deletions.

Overall Task Status

CategoryLast WeekThis WeekDelta
TODO8382-1
In Progress99
Completed177180+3
GitHub Issues

Test Cases

CategoryLast WeekThis WeekDelta
Passing36293766+137
XFAIL1421+7
make check-rust

Bugs

CategoryLast WeekThis WeekDelta
TODO1917-2
In Progress34+1
Completed5961+2
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 – Traits80%83%+3%20th May 202127th Aug 2021
Control Flow 2 – Pattern Matching0%0%29th Oct 2021
Imports and Visibility0%0%TBD
Macros and cfg expansion0%0%TBD
Const Generics0%0%TBD
Intrinsics0%0%TBD
GitHub Milestones

Planned Activities

  • Complete TypeBounds checks
  • Merge missing test cases for casts and coercions

YouTube

You can also watch me present this on youtube:

Leave a Reply

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