|
| 1 | +# Contributing to rust_codegen_gcc |
| 2 | + |
| 3 | +Welcome to the rust_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 | +1. Install the required dependencies: |
| 10 | + - rustup (follow instructions on the [official website](https://rustup.rs)) |
| 11 | + - DejaGnu (for running libgccjit test suite) |
| 12 | + - Additional packages: `flex`, `libmpfr-dev`, `libgmp-dev`, `libmpc3`, `libmpc-dev` |
| 13 | + |
| 14 | +2. Clone and configure the repository: |
| 15 | + ```bash |
| 16 | + git clone https://github.com/rust-lang/rust_codegen_gcc |
| 17 | + cd rust_codegen_gcc |
| 18 | + cp config.example.toml config.toml |
| 19 | + ``` |
| 20 | + |
| 21 | +3. Build the project: |
| 22 | + ```bash |
| 23 | + ./y.sh prepare # downloads and patches sysroot |
| 24 | + ./y.sh build --sysroot --release |
| 25 | + ``` |
| 26 | + |
| 27 | +### Running Tests |
| 28 | + |
| 29 | +To verify your setup: |
| 30 | +```bash |
| 31 | +# Run the full test suite |
| 32 | +./y.sh test --release |
| 33 | + |
| 34 | +# Test with a simple program |
| 35 | +./y.sh cargo build --manifest-path tests/hello-world/Cargo.toml |
| 36 | +``` |
| 37 | + |
| 38 | +## Communication Channels |
| 39 | + |
| 40 | +- Matrix: Join our [Matrix channel](https://matrix.to/#/#rustc_codegen_gcc:matrix.org) |
| 41 | +- IRC: Join us on [IRC](https://web.libera.chat/#rustc_codegen_gcc) |
| 42 | +- GitHub Issues: For bug reports and feature discussions |
| 43 | + |
| 44 | +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. |
| 45 | + |
| 46 | +## Understanding Core Concepts |
| 47 | + |
| 48 | +### Project Structure |
| 49 | + |
| 50 | +The project consists of several key components: |
| 51 | +- The GCC backend integration through libgccjit |
| 52 | +- Rust compiler interface |
| 53 | +- Test infrastructure |
| 54 | + |
| 55 | +### Common Development Tasks |
| 56 | + |
| 57 | +#### Running Specific Tests |
| 58 | +To run a specific test: |
| 59 | +1. Individual test: `./y.sh test --test <test_name>` |
| 60 | +2. libgccjit tests: |
| 61 | + ```bash |
| 62 | + cd gcc-build/gcc |
| 63 | + make check-jit |
| 64 | + # For a specific test: |
| 65 | + make check-jit RUNTESTFLAGS="-v -v -v jit.exp=jit.dg/test-asm.cc" |
| 66 | + ``` |
| 67 | + |
| 68 | +#### Debugging Tools |
| 69 | +The project provides several environment variables for debugging: |
| 70 | +- `CG_GCCJIT_DUMP_MODULE`: Dumps a specific module |
| 71 | +- `CG_GCCJIT_DUMP_TO_FILE`: Creates C-like representation |
| 72 | +- `CG_GCCJIT_DUMP_RTL`: Shows Register Transfer Language output |
| 73 | + |
| 74 | +Full list of debugging options can be found in the README. |
| 75 | + |
| 76 | +## Making Contributions |
| 77 | + |
| 78 | +### Finding Issues to Work On |
| 79 | +1. Look for issues labeled with `good-first-issue` or `help-wanted` |
| 80 | +2. Check the project roadmap for larger initiatives |
| 81 | +3. Consider improving documentation or tests |
| 82 | + |
| 83 | +### Pull Request Process |
| 84 | +1. Fork the repository and create a new branch |
| 85 | +2. Make your changes with clear commit messages |
| 86 | +3. Add tests for new functionality |
| 87 | +4. Update documentation as needed |
| 88 | +5. Submit a PR with a description of your changes |
| 89 | + |
| 90 | +### Code Style Guidelines |
| 91 | +- Follow Rust standard coding conventions |
| 92 | +- Ensure your code passes `rustfmt` and `clippy` |
| 93 | +- Add comments explaining complex logic, especially in GCC interface code |
| 94 | + |
| 95 | +## Additional Resources |
| 96 | + |
| 97 | +- [Rustc Dev Guide](https://rustc-dev-guide.rust-lang.org/) |
| 98 | +- [GCC Internals Documentation](https://gcc.gnu.org/onlinedocs/gccint/) |
| 99 | +- Project-specific documentation in the `doc/` directory: |
| 100 | + - Common errors |
| 101 | + - Debugging GCC LTO |
| 102 | + - Git subtree sync |
| 103 | + - Sending patches to GCC |
| 104 | + |
| 105 | +## Getting Help |
| 106 | + |
| 107 | +If you're stuck or unsure about anything: |
| 108 | +1. Check the existing documentation in the `doc/` directory |
| 109 | +2. Ask in the IRC or Matrix channels |
| 110 | +3. Open a GitHub issue for technical problems |
| 111 | +4. Comment on the issue you're working on if you need guidance |
| 112 | + |
| 113 | +Remember that all contributions, including documentation improvements, bug reports, and feature requests, are valuable to the project. |
0 commit comments