Welcome to the rustc_codegen_gcc project! This guide will help you get started as a contributor. The project aims to provide a GCC codegen backend for rustc, allowing Rust compilation on platforms unsupported by LLVM and potentially improving runtime performance through GCC's optimizations.
For detailed setup instructions including dependencies, build steps, and initial testing, please refer to our README. The README contains the most up-to-date information on:
Once you've completed the setup process outlined in the README, you can proceed with the contributor-specific information below.
We encourage new contributors to join our communication channels and introduce themselves. Feel free to ask questions about where to start or discuss potential contributions.
The sysroot is the directory that stores the compiled standard library (core, alloc, std, test, …) and compiler built-ins. Rustup ships these libraries pre-compiled with LLVM.
rustc_codegen_gcc replaces LLVM with the GCC backend.
The freshly compiled sysroot ends up in build/build_sysroot/....
A rebuild of sysroot is needed when
Both backend and sysroot can be built using different profiles. That is exactly what the --sysroot, --release-sysroot and --release flag supported by the build system script y.sh take care of.
| Command | Backend Profile | Sysroot Profile | Usage Scenario |
|---|---|---|---|
./y.sh build | dev* | n/a | Build backend in dev mode with optimized dependencies without rebuilding sysroot |
./y.sh build --release | release (optimized) | n/a | Build backend in release mode with optimized dependencies without rebuilding sysroot |
./y.sh build --release --sysroot | release (optimized) | dev | Build backend in release mode with optimized dependencies and sysroot in dev mode (unoptimized) |
./y.sh build --sysroot | dev* | dev | Build backend in dev mode with optimized dependencies and sysroot in dev mode (unoptimized) |
./y.sh build --release-sysroot --sysroot | dev* | release (optimized) | Build backend in dev mode and sysroot in release mode, both with optimized dependencies |
* In dev mode, dependencies are compiled with optimizations, while the code of the backend itself is not.
Note: --release-sysroot must be used together with --sysroot.
To run specific tests, use appropriate flags such as:
./y.sh test --test-libcore./y.sh test --std-tests./y.sh test --cargo-tests -- <name of test>Additionally, you can run the tests of libgccjit:
# libgccjit tests cd gcc-build/gcc make check-jit # For a specific test: make check-jit RUNTESTFLAGS="-v -v -v jit.exp=jit.dg/test-asm.cc"
The project provides several environment variables for debugging:
CG_GCCJIT_DUMP_GIMPLE: Dumps the GIMPLE IRCG_RUSTFLAGS: Additional Rust flagsCG_GCCJIT_DUMP_MODULE: Dumps a specific moduleCG_GCCJIT_DUMP_TO_FILE: Creates C-like representationFull list of debugging options can be found in the README.
good first issue or help wantedfailing-ui-tests12.txt)rustfmt and clippydoc/ directory:If you're stuck or unsure about anything:
doc/ directoryRemember that all contributions, including documentation improvements, bug reports, and feature requests, are valuable to the project.