Thanks again to Open Source Security, inc and Embecosm for their ongoing support for this project.
This beginning of the year was quite productive, with 41 pull-requests
merged and numerous core problems discovered and addressed.
Our work on getting the kernel to compile is focused on the crates
surrounding the main kernel crate. Pierre-Emmanuel has also been
focusing on the numerous nightly unstable features used by the kernel,
as gccrs will need to support them rather quickly. On a related note,
one nightly feature we have implemented this month - but which is not
essential to the kernel - is #![no_core]. gccrs now properly tries
to link your Rust program with core, which since we cannot compile
core yet, means all of our testsuite has to opt out of that linkage
using the #![no_core] attribute. Unfortunately, this commit was so big
that the changelog for it was rejected by the mailing list’s spam
filter. Heh.
In other news, Pierre-Emmanuel updated the GCC wiki with project ideas for this year’s Google Summer of Code: https://gcc.gnu.org/wiki/SummerOfCode%C2%A0
Feel free to propose any project you’d be interested in working on! Please join our Zulip group chat in order to start discussing with the team if you plan on applying for GSoC.
On a final technical note, one of the issues discovered with core this
month was an interesting edge-case in our import resolution algorithm we
had failed to consider:
Our naive approach to import definitions was to directly insert the ID of the node that the import would resolve to. For example, in the following example,
mod foo { // Definition ID 1
fn bar() {} // Definition ID 2
}
use foo::bar;
fn main() { // Definition ID 3
bar();
}
We’d “replace” the import by a direct insert of Definition ID 2, and
have the call to bar directly resolve to the function instead of
resolving to the import. This is fine in most cases, and went
unnoticed for a long period of time.
mod foo { // Definition ID 1
fn bar() {} // Definition ID 2
}
use foo::bar; // Resolved to Definition ID 2, insert Definition ID 2
fn main() { // Definition ID 3
bar(); // Resolved to Definition ID 2
}
For the most part, resolving to a reference to a definition or to the definition itself does not make a difference - the proper function gets called, typechecked, and everyone is happy. However, imports must act as a proper definition point, just like functions or modules. The correct way to resolve the above example is as follows:
mod foo { // Definition ID 1
fn bar() {} // Definition ID 2
}
use foo::bar; // Resolved to ID 2, Definition ID 3
fn main() { // Definition ID 4
bar(); // Resolved to ID 3
}
Consider this example:
use crate::intrinsics::{self, abort, is_aligned_and_not_null, is_nonoverlapping};
/* snip */
#[lang = "align_offset"]
pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {
use intrinsics::{
unchecked_shl, unchecked_shr, unchecked_sub, wrapping_add, wrapping_mul, wrapping_sub,
};
/* snip */
}
Here, the second import within the align_offset function directly
points to crate::intrinsics::self as a definition, and must be
understood this way. But the import does not contain any function
definitions, it merely points to the module which contains them. This
means that we must rework how our name resolution algorithm works for
itself, and for the output it produces for the rest of the compiler, as
later passes do not care about whether something is a definition or a
reference to a definition - they only want to work on the actual
modules, types and functions.
Up until this point, our name resolution worked with an internal structure that was also its output for later passes - a simple hashmap linking each usage-point to its definition-point:
HashMap<Usage, Definition> usage_map;
With Usage and Definition simply being newtype-patterns for a
NodeID, our internal ID structure for our AST nodes.
struct Usage(NodeId);
struct Definition(NodeId);
One possible modification is to modify the Definition type to allow
them to become references to other ~Definition~s:
struct Usage(NodeId);
enum Definition {
ImportOf(NodeId), // A use import
Actual(NodeId), // Literally anything else that is a definition
}
This transforms our simple map into a graph, which we can then traverse at the end of name resolution to turn it back into a regular map - essentially flat-mapping it for later passes. This approach also allows us to do import loop detection, something we had not given much thought about previously as it is not essential for code-gen.
An issue with this implementation is that when inserting usage-points in
our usage_map, we must know whether or not the NodeId that we
resolved to in our NameResolutionCtx ribs is an import, or an actual
definition. This has multiple ramifications and requires multiple
changes to our internal name resolution structures, while also
increasing their memory usage. Thankfully, we can easily avoid much of
these changes thanks to one trick - if a Definition is also present in
the map as a key, then it must mean that it is an import!
By traversing the map recursively as a graph and checking if each definition is also present as a key, we can easily avoid a lot of code churn and still produce the output expected by later compiler passes.
We will not have a community call this month as most of the team will be traveling. 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.
| Category | Last Month | This Month | Delta |
|---|---|---|---|
| TODO | 409 | 407 | -2 |
| In Progress | 118 | 114 | -4 |
| Completed | 1194 | 1217 | +23 |
| Category | Last Month | This Month | Delta |
|---|---|---|---|
| TODO | 194 | 195 | +1 |
| In Progress | 56 | 52 | -4 |
| Completed | 591 | 600 | +9 |
| TestCases | Last Month | This Month | Delta |
|---|---|---|---|
| Passing | 10470 | 10563 | +93 |
| Failed | - | - | - |
| XFAIL | 73 | 73 | - |
| XPASS | - | - | - |
| Milestone | Last Month | This Month | Delta | Start Date | Completion Date | Target | Target GCC |
|---|---|---|---|---|---|---|---|
| Rust-for-Linux | 12% | 12% | - | 1st Nov 2025 | - | - | GCC 16.1 |
| Full core Late nameres issues | 15% | 20% | +5% | 1st Dec 2025 | - | - | GCC 16.1 |
| Full core Early nameres issues | 90% | 95% | +5% | 1st Dec 2025 | - | - | GCC 16.1 |
| Full core Typecheck issues | 0% | 7% | +7% | 21st Jan 2026 | - | - | GCC 16.1 |
| Upcoming Milestone | Last Month | This Month | Delta | Start Date | Completion Date | Target | Target GCC |
|---|---|---|---|---|---|---|---|
| Unstable RfL features | 0% | 0% | - | 7th Jan 2025 | - | 1st Aug 2025 | GCC 16.1 |
| Generic Associated Types | 0% | 0% | - | 15th Mar 2025 | - | 15th Jun 2025 | GCC 16.1 |
| RfL const generics | 0% | 0% | - | 1st May 2025 | - | 15th Jun 2025 | GCC 16.1 |
| frontend plugin hooks | 0% | 0% | - | 15th May 2025 | - | 7th Jul 2025 | GCC 16.1 |
| Handling the testsuite issues | 0% | 0% | - | 15th Sep 2024 | - | 15th Sep 2025 | GCC 16.1 |
| main shim | 0% | 0% | - | 28th Jul 2025 | - | 15th Sep 2025 | GCC 16.1 |
| Final core attributes | 0% | 0% | - | - | GCC 16.1 | ||
| Core nightly features | 0% | 0% | - | - | GCC 16.1 | ||
| Defered inference | 0% | 0% | - | - | GCC 16.1 | ||
| Fn traits fixes | 0% | 0% | - | - | GCC 16.1 | ||
| Recursive types | 0% | 0% | - | - | GCC 16.1 | ||
| Drop | 0% | 0% | - | - | GCC 16.1 | ||
| Pin, PinInit | 0% | 0% | - | - | GCC 16.1 |
| Past Milestone | Last Month | This Month | Delta | Start Date | Completion Date | Target | Target GCC |
|---|---|---|---|---|---|---|---|
| Data Structures 1 - Core | 100% | 100% | - | 30th Nov 2020 | 27th Jan 2021 | 29th Jan 2021 | GCC 14.1 |
| Control Flow 1 - Core | 100% | 100% | - | 28th Jan 2021 | 10th Feb 2021 | 26th Feb 2021 | GCC 14.1 |
| Data Structures 2 - Generics | 100% | 100% | - | 11th Feb 2021 | 14th May 2021 | 28th May 2021 | GCC 14.1 |
| Data Structures 3 - Traits | 100% | 100% | - | 20th May 2021 | 17th Sep 2021 | 27th Aug 2021 | GCC 14.1 |
| Control Flow 2 - Pattern Matching | 100% | 100% | - | 20th Sep 2021 | 9th Dec 2021 | 29th Nov 2021 | GCC 14.1 |
| Macros and cfg expansion | 100% | 100% | - | 1st Dec 2021 | 31st Mar 2022 | 28th Mar 2022 | GCC 14.1 |
| Imports and Visibility | 100% | 100% | - | 29th Mar 2022 | 13th Jul 2022 | 27th May 2022 | GCC 14.1 |
| Const Generics | 100% | 100% | - | 30th May 2022 | 10th Oct 2022 | 17th Oct 2022 | GCC 14.1 |
| Initial upstream patches | 100% | 100% | - | 10th Oct 2022 | 13th Nov 2022 | 13th Nov 2022 | GCC 14.1 |
| Upstream initial patchset | 100% | 100% | - | 13th Nov 2022 | 13th Dec 2022 | 19th Dec 2022 | GCC 14.1 |
| Update GCC’s master branch | 100% | 100% | - | 1st Jan 2023 | 21st Feb 2023 | 3rd Mar 2023 | GCC 14.1 |
| Final set of upstream patches | 100% | 100% | - | 16th Nov 2022 | 1st May 2023 | 30th Apr 2023 | GCC 14.1 |
| Borrow Checking 1 | 100% | 100% | - | TBD | 8th Jan 2024 | 15th Aug 2023 | GCC 14.1 |
| Procedural Macros 1 | 100% | 100% | - | 13th Apr 2023 | 6th Aug 2023 | 6th Aug 2023 | GCC 14.1 |
| GCC 13.2 Release | 100% | 100% | - | 13th Apr 2023 | 22nd Jul 2023 | 15th Jul 2023 | GCC 14.1 |
| GCC 14 Stage 3 | 100% | 100% | - | 1st Sep 2023 | 20th Sep 2023 | 1st Nov 2023 | GCC 14.1 |
| GCC 14.1 Release | 100% | 100% | - | 2nd Jan 2024 | 2nd Jun 2024 | 15th Apr 2024 | GCC 14.1 |
| formatargs!() support | 100% | 100% | - | 15th Feb 2024 | - | 1st Apr 2024 | GCC 14.1 |
| GCC 14.2 | 100% | 100% | - | 7th Jun 2024 | 15th Jun 2024 | 15th Jun 2024 | GCC 14.2 |
| GCC 15.1 | 100% | 100% | - | 21st Jun 2024 | 31st Jun 2024 | 1st Jul 2024 | GCC 15.1 |
| Unhandled attributes | 100% | 100% | - | 1st Jul 2024 | 15th Aug 2024 | 15th Aug 2024 | GCC 15.1 |
| Inline assembly | 100% | 100% | - | 1st Jun 2024 | 26th Aug 2024 | 15th Sep 2024 | GCC 15.1 |
| Rustc Testsuite Adaptor | 100% | 100% | - | 1st Jun 2024 | 26th Aug 2024 | 15th Sep 2024 | GCC 15.1 |
| Borrow checker improvements | 100% | 100% | - | 1st Jun 2024 | 26th Aug 2024 | 15th Sep 2024 | GCC 15.1 |
| Deref and DerefMut improvements | 100% | 100% | - | 28th Sep 2024 | 25th Oct 2024 | 28th Dec 2024 | GCC 15.1 |
| Indexing fixes | 100% | 100% | - | 21st Jul 2024 | 25th Dec 2024 | 15th Nov 2024 | GCC 15.1 |
| Iterator fixes | 100% | 100% | - | 21st Jul 2024 | 25th Dec 2024 | 15th Nov 2024 | GCC 15.1 |
| Auto traits improvements | 100% | 100% | - | 15th Sep 2024 | 20th Jan 2025 | 21st Dec 2024 | GCC 15.1 |
| Lang items | 100% | 100% | - | 1st Jul 2024 | 10th Jan 2025 | 21st Nov 2024 | GCC 15.1 |
| alloc parser issues | 100% | 100% | - | 7th Jan 2025 | 31st Jun 2024 | 28th Jan 2025 | GCC 15.1 |
| std parser issues | 100% | 100% | - | 7th Jan 2025 | 31st Jun 2024 | 28th Jan 2025 | GCC 16.1 |
| Question mark operator | 100% | 100% | - | 15th Dec 2024 | 21st Feb 2025 | 21st Feb 2025 | GCC 15.1 |
| Name resolution 2.0 rework | 100% | 100% | - | 1st Jun 2024 | - | 1st Apr 2025 | GCC 15.1 |
| Macro expansion | 100% | 100% | - | 1st Jun 2024 | - | 1st Jan 2025 | GCC 15.1 |
| Remaining typecheck issues | 100% | 100% | - | 21st Oct 2024 | - | 1st Mar 2025 | GCC 15.1 |
| cfg-core | 100% | 100% | - | 1st Dec 2024 | 24th Mar 2025 | 1st Mar 2025 | GCC 15.1 |
| Codegen fixes | 100% | 100% | - | 7th Oct 2024 | 1st Apr 2025 | 1st Mar 2025 | GCC 15.1 |
| blackbox intrinsic | 100% | 100% | - | 28th Oct 2024 | - | 28th Jan 2025 | GCC 15.1 |
| let-else | 100% | 100% | - | 28th Jan 2025 | - | 28th Feb 2025 | GCC 15.1 |
| Specialization | 100% | 100% | - | 1st Jan 2025 | 1st Apr 2025 | 1st Mar 2025 | GCC 15.1 |
| cfg-rfl | 100% | 100% | - | 7th Jan 2025 | 19th Mar 2025 | 15th Feb 2025 | GCC 15.1 |
| Downgrade to Rust 1.49 | 100% | 100% | - | 14th Mar 2025 | 26th Mar 2025 | 1st Apr 2025 | GCC 15.1 |
| try blocks | 100% | 100% | - | 30th Jul 2025 | GCC 16.1 | ||
| while-let loops | 100% | 100% | - | 30th Jul 2025 | GCC 16.1 | ||
| offsetof!() builtin macro | 100% | 100% | - | 15th Mar 2025 | 4th Aug 2025 | 15th Aug 2025 | GCC 16.1 |
| Explicit generics with impl Trait | 100% | 100% | - | 28th Feb 2025 | 21st Jul 2025 | 28th Mar 2025 | GCC 16.1 |
| Final Inline assembly fixes | 100% | 100% | - | - | GCC 16.1 |