rustc_codegen_gcc: Progress Report #37
What is rustc_codegen_gcc?
rustc_codegen_gcc is a GCC ahead-of-time codegen for rustc, meaning that it can be loaded by the existing rustc frontend, but benefits from GCC by having more architectures supported and having access to GCC’s optimizations. It is not to be confused with gccrs, which is a GCC frontend for Rust.
GCC patches status
No progress on this front in the past month.
State of rustc_codegen_gcc
Here’s what has been done during the past months:
-
Use
tempfile::TempDir::keep()
instead of deprecatedinto_path()
(thanks to emmanuel-ferdman!) -
Added support for testing the backend with abi-cafe (thanks to FractalFir!)
-
Fix fuzz warnings and deny warnings by default in build system (thanks to GuillaumeGomez!)
-
Fixed some clippy warnings. (thanks to FractalFir!)
-
Skip needless calls to get_align in some cases. (thanks to FractalFir!)
-
Refactored the codebase to use Function instead of RValue where possible. (thanks to FractalFir!)
-
Remove unnecesary uses of the 'current_func' field, replacing it with a call to function. (thanks to FractalFir!)
-
Fix to show the complete LLVM intrinsic name when it is unimplemented (thanks to FractalFir!)
-
Change the implementation of supports_parallel to signal tha cg_gcc is not thread safe. (thanks to FractalFir!)
-
Inserted a local variable in volatile_load, to ensure reads don’t move across blocks. (thanks to FractalFir!)
-
Skip needlessly setting the default visibility on functions (thanks to FractalFir!)
-
Regenerate intrinsics mapping (thanks to GuillaumeGomez!)
-
Update gccjit dependency and libgccjit commit (thanks to GuillaumeGomez!)
-
Fmt tests run (thanks to dvermd!)
As you can see, we still got many contributions from FractalFir, which is doing the Google Summer of Code with us this year: we’re super happy to have such a talented person helping us moving things forward!
On the side of the Rust repo, we got progress on running more tests of rustc_codegen_gcc
in the Rust CI:
-
Add new
ignore-backends
andneeds-backends
tests annotations (thanks to GuillaumeGomez!) -
Rename
tests/{assembly,codegen}
intotests/{assembly,codegen}-llvm
and ignore these testsuites if configured backend doesn’t match (thanks to GuillaumeGomez!) -
Add ignore-backends annotations in failing GCC backend ui tests (thanks to GuillaumeGomez!)
-
Add new --test-codegen-backend bootstrap option (thanks to GuillaumeGomez!)
and progress towards having rustup distribution:
-
Copy GCC sources into the build directory even outside CI (thanks to Kobzol!)
-
Refactor codegen backends in bootstrap (thanks to Kobzol!)
-
Install libgccjit into the compiler’s sysroot when cg_gcc is enabled (thanks to Kobzol!)
-
Download CI GCC into the correct directory (thanks to Kobzol!)
In the next month, I plan to continue sending patches to GCC to get reviews so that they can get merged in time for the next release of GCC.
Here’s a rough summary of what has been implemented:
Feature | Last month completion | Completion | Delta |
---|---|---|---|
Run tests in the Rust CI |
0% |
30% |
+30% |
Rustup distribution. |
30% |
40% |
+10% |
Unwinding. |
80% |
80% |
|
LTO. |
80% |
80% |
|
More function and variable attributes. |
22% |
22% |
|
Target features (to detect what is supported in an architecture, like SIMD). |
82% |
82% |
|
Debug info. |
20% |
20% |
|
Thin LTO. |
5% |
5% |
|
SIMD for other architectures than x86-64. |
0% |
||
Support for new architectures in libraries (libc, object, …) and rustc. |
0% |
||
Refactor to rustc_codegen_ssa to make it easier for the GCC codegen |
0% |
||
Endianness support for non-native 128-bit integers. |
Done |
||
SIMD (x86-64). |
Done |
||
Basic and aggregate types. |
Done |
||
Operations, local and global variables, constants, functions, basic blocks. |
Done |
||
Atomics. |
Done |
||
Thread-local storage. |
Done |
||
Inline assembly. |
Done |
||
Many intrinsics. |
Done |
||
Metadata. |
Done |
||
Setting optimization level. |
Done |
||
Packed structures. |
Done |
||
Alignment, symbol visibility, attributes. |
Done |
||
128-bit integers. |
Done |
UI tests progress
Here are the results of running the UI tests in the CI:
-
https://github.com/rust-lang/rustc_codegen_gcc/actions/runs/16971110900/job/48108045682#step:18:4035
-
https://github.com/rust-lang/rustc_codegen_gcc/actions/runs/16971110900/job/48108045684#step:18:4028
-
https://github.com/rust-lang/rustc_codegen_gcc/actions/runs/16970015645#summary-48104146696 (failures)
Category | Last Month | This Month | Delta |
---|---|---|---|
Passed |
6303 |
6507 |
+204 |
Failed |
43 |
48 |
+5 |
How to contribute
rustc_codegen_gcc
If you want to help on the project itself, please do the following:
-
Run the tests locally.
-
Choose a test that fails.
-
Investigate why it fails.
-
Fix the problem.
Even if you can’t fix the problem, your investigation could help, so if you enjoy staring at assembly code, have fun!
Crates and rustc
If you would like to contribute on adding support for Rust on
currently unsupported platforms, you can help by adding the support
for those platforms in some crates like libc
and object
and also
in the rust compiler itself.
Test this project
Otherwise, you can test this project on new platforms and also compare the assembly with LLVM to see if some optimization is missing.
To do so, follow these instructions to build the project and run a program via the cargo
command of our script.
If you find a bug, please open an issue.
Good first issue
Finally, another good way to help is to look at good first issues. Those are issues that should be easier to start with.
Thanks for your support!
I wanted to personally thank all the people that sponsor this project: your support is very much appreciated.
A special thanks to the following sponsors:
-
Futurewei
-
Shnatsel
-
Rust Foundation
A big thank you to bjorn3 for his help, contributions and reviews. And a big thank you to lqd and GuillaumeGomez for answering my questions about rustc’s internals and to Kobzol and GuillaumeGomez for their contributions. Another big thank you to Commeownist for his contributions.
Also, a big thank you to the rest of my sponsors:
-
kpp
-
0x7CFE
-
oleid
-
joshtriplett
-
djc
-
sdroege
-
pcn
-
alanfalloon
-
davidlattimore
-
colelawrence
-
zmanian
-
berkus
-
belzael
-
yvt
-
yerke
-
srijs
-
kkysen
-
riking
-
Lemmih
-
memoryruins
-
senden9
-
robjtede
-
Jonas Platte
-
Sam Harrington
-
Jonas
-
Eugene Bulkin
-
Joseph Garvin
-
MarcoFalke
-
athre0z
-
Sebastian Zivota
-
Oskar Nehlin
-
Nicolas Barbier
-
Daniel
-
Justin Ossevoort
-
kiyoshigawa
-
Daniel Sheehan
-
Marvin Löbel
-
nacaclanga
-
0x0177b11f
-
L.apz
-
JockeTF
-
davidcornu
-
stuhood
-
Mauve
-
icewind1991
-
nicholasbishop
-
David Vasak
-
Eric Driggers
-
Olaf Leidinger
-
UtherII
-
simonlindholm
-
lemmih
-
Eddddddd
-
rrbutani
-
Mateusz K
-
thk1
-
teh
-
KirilMihaylov
-
Vladislav Sukhmel
-
ximou
-
Kate Kiesel
-
jplatte
-
VasanthakumarV
-
thesamesam
-
sbstp
-
g4titanx
-
teohhanhui
-
Laine Taffin Altman
-
LunNova
and a few others who preferred to stay anonymous.
Former sponsors/patreons:
-
igrr
-
embark-studios
-
saethlin
-
Traverse-Research
-
finfet
-
Alovchin91
-
wezm
-
mexus
-
raymanfx
-
ghost
-
gilescope
-
olanod
-
Denis Zaletaev
-
Chai T. Rex
-
Paul Ellenbogen
-
Dakota Brink
-
Botlabs
-
Cass
-
Oliver Marshall
-
pthariensflame
-
tedbyron
-
sstadick
-
Absolucy
-
rafaelcaricio
-
dandxy89
-
luizirber
-
regiontog
-
vincentdephily
-
zebp
-
Hofer-Julian
-
messense
-
fanquake
-
jam1garner
-
evanrichter
-
Nehliin
-
nevi-me
-
TimNN
-
steven-joruk
-
seanpianka
-
spike grobstein
-
Jeff Muizelaar
-
robinmoussu
-
Chris Butler
-
sierrafiveseven
-
icewind
-
Thomas Colliers
-
Tommy Thorn
-
Bálint Horváth
-
Matthew Conolly
-
Lapz
-
Myrik Lord
-
T
-
Emily A. Bellows
-
Chris
-
repi
-
opensrcsec
-
NobodyXu
-
alexkirsz
-
0xdeafbeef
-
l-const
-
CohenArthur
-
bes
-
acshi
-
Shoeboxam