October 5th, 2024

(Re)Using rustc components in gccrs

The gccrs project is developing an alternative Rust compiler by integrating components from rustc, starting with rustc_parse_format and planning to include polonius, while addressing internal representation challenges.

Read original articleLink Icon
(Re)Using rustc components in gccrs

The gccrs project aims to develop an alternative Rust compiler using components from the official Rust compiler (rustc) to ensure compatibility and performance. The team has begun integrating various rustc components, starting with rustc_parse_format, which parses Rust format strings for proper string formatting and inline assembly. This integration is crucial for maintaining consistent behavior between gccrs and rustc, especially in complex areas like borrow-checking. The next significant component planned for integration is polonius, a next-generation borrow-checker that enhances the current borrow-checking algorithm. The project faces challenges due to the differences in internal representations between gccrs (written in C++) and rustc (written in Rust), which complicates the reuse of components. The team is committed to ensuring that gccrs mirrors rustc's behavior to avoid discrepancies in error handling and runtime behavior. Currently, gccrs relies on rustc and Cargo to compile these components, with plans to fully integrate them once gccrs is more mature. The bootstrapping process involves creating an intermediate compiler to facilitate the integration of Rust components, ultimately leading to a fully functional Rust compiler with enhanced capabilities.

- gccrs is developing an alternative Rust compiler by reusing components from rustc.

- The first integrated component is rustc_parse_format, which handles Rust format strings.

- Future integration includes polonius, a next-generation borrow-checker.

- Differences in internal representations between gccrs and rustc pose challenges for component reuse.

- The project aims to ensure consistent behavior between gccrs and rustc, particularly in error handling.

Link Icon 5 comments
By @theobeers - 7 months
An interesting bit, on not making it too easy for people to circumvent the borrow checker:

> First, we use a C++ compiler to build gccrs, disabling the borrow-checking pass of the compiler. It is important to ensure borrow-checking cannot be disabled at runtime using a command line flag, as this could have a negative impact on the Rust ecosystem – however, building gccrs without borrow-checking to use it as an intermediate compiler in our bootstrapping process is okay.

By @loeg - 7 months
Love seeing updates / progress on gccrs.
By @jenadine - 7 months
Why not reuse the whole frontend then?
By @PoignardAzur - 7 months
I'm kind of curious how many components you can jettison from a Rust compiler and still be able to build these libraries.

It's not like Polonius or the trait solver were designed with bootstrapping gccrs in mind.

By @pitaj - 7 months
Makes sense