Skip to content

Commit 6d8fffe

Browse files
authored
Merge pull request #586 from g4titanx/contributing
improve doc for new contributors
2 parents 72b6614 + 43747ce commit 6d8fffe

File tree

2 files changed

+120
-13
lines changed

2 files changed

+120
-13
lines changed

CONTRIBUTING.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Contributing to rustc_codegen_gcc
2+
3+
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.
4+
5+
## Getting Started
6+
7+
### Setting Up Your Development Environment
8+
9+
For detailed setup instructions including dependencies, build steps, and initial testing, please refer to our [README](Readme.md). The README contains the most up-to-date information on:
10+
11+
- Required dependencies and system packages
12+
- Repository setup and configuration
13+
- Build process
14+
- Basic test verification
15+
16+
Once you've completed the setup process outlined in the README, you can proceed with the contributor-specific information below.
17+
18+
## Communication Channels
19+
20+
- Matrix: Join our [Matrix channel](https://matrix.to/#/#rustc_codegen_gcc:matrix.org)
21+
- IRC: Join us on [IRC](https://web.libera.chat/#rustc_codegen_gcc)
22+
- GitHub Issues: For bug reports and feature discussions
23+
24+
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.
25+
26+
## Understanding Core Concepts
27+
28+
### Common Development Tasks
29+
30+
#### Running Specific Tests
31+
To run specific tests, use appropriate flags such as:
32+
- `./y.sh test --test-libcore`
33+
- `./y.sh test --std-tests`
34+
- `cargo test -- <name of test>`
35+
36+
Additionally, you can run the tests of `libgccjit`:
37+
```bash
38+
# libgccjit tests
39+
cd gcc-build/gcc
40+
make check-jit
41+
# For a specific test:
42+
make check-jit RUNTESTFLAGS="-v -v -v jit.exp=jit.dg/test-asm.cc"
43+
```
44+
45+
#### Debugging Tools
46+
The project provides several environment variables for debugging:
47+
- `CG_GCCJIT_DUMP_GIMPLE`: Dump the GIMPLE IR
48+
- `CG_RUSTFLAGS`: Additional Rust flags
49+
- `CG_GCCJIT_DUMP_MODULE`: Dumps a specific module
50+
- `CG_GCCJIT_DUMP_TO_FILE`: Creates C-like representation
51+
52+
Full list of debugging options can be found in the [README](Readme.md#env-vars).
53+
54+
## Making Contributions
55+
56+
### Finding Issues to Work On
57+
1. Look for issues labeled with [`good first issue`](https://github.com/rust-lang/rustc_codegen_gcc/issues?q=is%3Aissue%20state%3Aopen%20label%3A"good%20first%20issue") or [`help wanted`](https://github.com/rust-lang/rustc_codegen_gcc/issues?q=is%3Aissue%20state%3Aopen%20label%3A"help%20wanted")
58+
2. Check the [progress report](https://blog.antoyo.xyz/rustc_codegen_gcc-progress-report-34#state_of_rustc_codegen_gcc) for larger initiatives
59+
3. Consider improving documentation or investigating [failing tests](https://github.com/rust-lang/rustc_codegen_gcc/tree/master/tests) (except `failing-ui-tests12.txt`)
60+
61+
### Pull Request Process
62+
1. Fork the repository and create a new branch
63+
2. Make your changes with clear commit messages
64+
3. Add tests for new functionality
65+
4. Update documentation as needed
66+
5. Submit a PR with a description of your changes
67+
68+
### Code Style Guidelines
69+
- Follow Rust standard coding conventions
70+
- Ensure your code passes `rustfmt` and `clippy`
71+
- Add comments explaining complex logic, especially in GCC interface code
72+
73+
## Additional Resources
74+
75+
- [Rustc Dev Guide](https://rustc-dev-guide.rust-lang.org/)
76+
- [GCC Internals Documentation](https://gcc.gnu.org/onlinedocs/gccint/)
77+
- Project-specific documentation in the `doc/` directory:
78+
- [Common errors](doc/errors.md)
79+
- [Debugging](doc/debugging.md)
80+
- [Debugging libgccjit](doc/debugging-libgccjit.md)
81+
- [Git subtree sync](doc/subtree.md)
82+
- [List of useful commands](doc/tips.md)
83+
- [Send a patch to GCC](doc/sending-gcc-patch.md)
84+
85+
## Getting Help
86+
87+
If you're stuck or unsure about anything:
88+
1. Check the existing documentation in the `doc/` directory
89+
2. Ask in the IRC or Matrix channels
90+
3. Open a GitHub issue for technical problems
91+
4. Comment on the issue you're working on if you need guidance
92+
93+
Remember that all contributions, including documentation improvements, bug reports, and feature requests, are valuable to the project.

Readme.md

+27-13
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,36 @@ This is a GCC codegen for rustc, which means it can be loaded by the existing ru
1212
The primary goal of this project is to be able to compile Rust code on platforms unsupported by LLVM.
1313
A secondary goal is to check if using the gcc backend will provide any run-time speed improvement for the programs compiled using rustc.
1414

15-
### Dependencies
16-
17-
**rustup:** Follow the instructions on the official [website](https://www.rust-lang.org/tools/install)
18-
19-
**DejaGnu:** Consider to install DejaGnu which is necessary for running the libgccjit test suite. [website](https://www.gnu.org/software/dejagnu/#downloading)
20-
21-
15+
## Getting Started
2216

23-
## Building
24-
25-
**This requires a patched libgccjit in order to work.
17+
Note: **This requires a patched libgccjit in order to work.
2618
You need to use my [fork of gcc](https://github.com/rust-lang/gcc) which already includes these patches.**
19+
The default configuration (see below in the [Quick start](#quick-start) section) will download a `libgccjit` built in the CI that already contains these patches, so you don't need to build this fork yourself if you use the default configuration.
2720

28-
```bash
29-
$ cp config.example.toml config.toml
30-
```
21+
### Dependencies
22+
- rustup: follow instructions on the [official website](https://rustup.rs)
23+
- consider to install DejaGnu which is necessary for running the libgccjit test suite. [website](https://www.gnu.org/software/dejagnu/#downloading)
24+
- additional packages: `flex`, `libmpfr-dev`, `libgmp-dev`, `libmpc3`, `libmpc-dev`
25+
26+
### Quick start
27+
1. Clone and configure the repository:
28+
```bash
29+
git clone https://github.com/rust-lang/rustc_codegen_gcc
30+
cd rustc_codegen_gcc
31+
cp config.example.toml config.toml
32+
```
33+
34+
2. Build and test:
35+
```bash
36+
./y.sh prepare # downloads and patches sysroot
37+
./y.sh build --sysroot --release
38+
39+
# Verify setup with a simple test
40+
./y.sh cargo build --manifest-path tests/hello-world/Cargo.toml
41+
42+
# Run full test suite (expect ~100 failing UI tests)
43+
./y.sh test --release
44+
```
3145

3246
If don't need to test GCC patches you wrote in our GCC fork, then the default configuration should
3347
be all you need. You can update the `rustc_codegen_gcc` without worrying about GCC.

0 commit comments

Comments
 (0)