From 62978b326a66f9e68ba762ca313076819cf37408 Mon Sep 17 00:00:00 2001 From: g4titanx Date: Fri, 3 Jan 2025 07:58:23 +0100 Subject: [PATCH 1/2] add contibuting.md --- CONTRIBUTING.md | 113 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..3bddb6ac63b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,113 @@ +# Contributing to rust_codegen_gcc + +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. + +## Getting Started + +### Setting Up Your Development Environment + +1. Install the required dependencies: + - rustup (follow instructions on the [official website](https://rustup.rs)) + - DejaGnu (for running libgccjit test suite) + - Additional packages: `flex`, `libmpfr-dev`, `libgmp-dev`, `libmpc3`, `libmpc-dev` + +2. Clone and configure the repository: + ```bash + git clone https://github.com/rust-lang/rust_codegen_gcc + cd rust_codegen_gcc + cp config.example.toml config.toml + ``` + +3. Build the project: + ```bash + ./y.sh prepare # downloads and patches sysroot + ./y.sh build --sysroot --release + ``` + +### Running Tests + +To verify your setup: +```bash +# Run the full test suite +./y.sh test --release + +# Test with a simple program +./y.sh cargo build --manifest-path tests/hello-world/Cargo.toml +``` + +## Communication Channels + +- Matrix: Join our [Matrix channel](https://matrix.to/#/#rustc_codegen_gcc:matrix.org) +- IRC: Join us on [IRC](https://web.libera.chat/#rustc_codegen_gcc) +- GitHub Issues: For bug reports and feature discussions + +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. + +## Understanding Core Concepts + +### Project Structure + +The project consists of several key components: +- The GCC backend integration through libgccjit +- Rust compiler interface +- Test infrastructure + +### Common Development Tasks + +#### Running Specific Tests +To run a specific test: +1. Individual test: `./y.sh test --test ` +2. libgccjit tests: + ```bash + 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" + ``` + +#### Debugging Tools +The project provides several environment variables for debugging: +- `CG_GCCJIT_DUMP_MODULE`: Dumps a specific module +- `CG_GCCJIT_DUMP_TO_FILE`: Creates C-like representation +- `CG_GCCJIT_DUMP_RTL`: Shows Register Transfer Language output + +Full list of debugging options can be found in the README. + +## Making Contributions + +### Finding Issues to Work On +1. Look for issues labeled with `good-first-issue` or `help-wanted` +2. Check the project roadmap for larger initiatives +3. Consider improving documentation or tests + +### Pull Request Process +1. Fork the repository and create a new branch +2. Make your changes with clear commit messages +3. Add tests for new functionality +4. Update documentation as needed +5. Submit a PR with a description of your changes + +### Code Style Guidelines +- Follow Rust standard coding conventions +- Ensure your code passes `rustfmt` and `clippy` +- Add comments explaining complex logic, especially in GCC interface code + +## Additional Resources + +- [Rustc Dev Guide](https://rustc-dev-guide.rust-lang.org/) +- [GCC Internals Documentation](https://gcc.gnu.org/onlinedocs/gccint/) +- Project-specific documentation in the `doc/` directory: + - Common errors + - Debugging GCC LTO + - Git subtree sync + - Sending patches to GCC + +## Getting Help + +If you're stuck or unsure about anything: +1. Check the existing documentation in the `doc/` directory +2. Ask in the IRC or Matrix channels +3. Open a GitHub issue for technical problems +4. Comment on the issue you're working on if you need guidance + +Remember that all contributions, including documentation improvements, bug reports, and feature requests, are valuable to the project. \ No newline at end of file From 2fc138fc493e9aff8d3fe8858d9fd7b7577d7a39 Mon Sep 17 00:00:00 2001 From: g4titanx Date: Fri, 7 Feb 2025 11:22:21 +0100 Subject: [PATCH 2/2] modify docs --- CONTRIBUTING.md | 81 ++++++++++++++++++------------------------------- Readme.md | 43 +++++++++++++++++--------- 2 files changed, 58 insertions(+), 66 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3bddb6ac63b..85ddb6c8f46 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,39 +1,19 @@ # Contributing to rust_codegen_gcc -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. +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. ## Getting Started ### Setting Up Your Development Environment -1. Install the required dependencies: - - rustup (follow instructions on the [official website](https://rustup.rs)) - - DejaGnu (for running libgccjit test suite) - - Additional packages: `flex`, `libmpfr-dev`, `libgmp-dev`, `libmpc3`, `libmpc-dev` +For detailed setup instructions including dependencies, build steps, and initial testing, please refer to our [README](https://github.com/rust-lang/rustc_codegen_gcc/blob/master/Readme.md). The README contains the most up-to-date information on: -2. Clone and configure the repository: - ```bash - git clone https://github.com/rust-lang/rust_codegen_gcc - cd rust_codegen_gcc - cp config.example.toml config.toml - ``` +- Required dependencies and system packages +- Repository setup and configuration +- Build process +- Basic test verification -3. Build the project: - ```bash - ./y.sh prepare # downloads and patches sysroot - ./y.sh build --sysroot --release - ``` - -### Running Tests - -To verify your setup: -```bash -# Run the full test suite -./y.sh test --release - -# Test with a simple program -./y.sh cargo build --manifest-path tests/hello-world/Cargo.toml -``` +Once you've completed the setup process outlined in the README, you can proceed with the contributor-specific information below. ## Communication Channels @@ -45,31 +25,28 @@ We encourage new contributors to join our communication channels and introduce t ## Understanding Core Concepts -### Project Structure - -The project consists of several key components: -- The GCC backend integration through libgccjit -- Rust compiler interface -- Test infrastructure - ### Common Development Tasks #### Running Specific Tests -To run a specific test: -1. Individual test: `./y.sh test --test ` -2. libgccjit tests: - ```bash - 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" - ``` +To run specific tests, use appropriate flags such as: +- `./y.sh test --test-libcore` +- `./y.sh test --std-tests` + +Additional test running options: +```bash +# 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" +``` #### Debugging Tools The project provides several environment variables for debugging: +- `CG_GCCJIT_DUMP_GIMPLE`: Most commonly used debug dump +- `CG_RUSTFLAGS`: Additional Rust compiler flags - `CG_GCCJIT_DUMP_MODULE`: Dumps a specific module - `CG_GCCJIT_DUMP_TO_FILE`: Creates C-like representation -- `CG_GCCJIT_DUMP_RTL`: Shows Register Transfer Language output Full list of debugging options can be found in the README. @@ -77,8 +54,8 @@ Full list of debugging options can be found in the README. ### Finding Issues to Work On 1. Look for issues labeled with `good-first-issue` or `help-wanted` -2. Check the project roadmap for larger initiatives -3. Consider improving documentation or tests +2. Check the [progress report](https://blog.antoyo.xyz/rustc_codegen_gcc-progress-report-34#state_of_rustc_codegen_gcc) for larger initiatives +3. Consider improving documentation or investigate [failing tests](https://github.com/rust-lang/rustc_codegen_gcc/tree/master/tests)(except failing-ui-tests12.txt) ### Pull Request Process 1. Fork the repository and create a new branch @@ -97,10 +74,12 @@ Full list of debugging options can be found in the README. - [Rustc Dev Guide](https://rustc-dev-guide.rust-lang.org/) - [GCC Internals Documentation](https://gcc.gnu.org/onlinedocs/gccint/) - Project-specific documentation in the `doc/` directory: - - Common errors - - Debugging GCC LTO - - Git subtree sync - - Sending patches to GCC + - [Common errors](./doc/errors.md) + - [Debugging GCC LTO](./doc/debugging-gcc-lto.md) + - [Debugging libgccjit](./doc/debugging-libgccjit.md) + - [Git subtree sync](./doc/subtree.md) + - [List of useful commands](./doc/tips.md) + - [Send a patch to GCC](./doc/sending-gcc-patch.md) ## Getting Help @@ -110,4 +89,4 @@ If you're stuck or unsure about anything: 3. Open a GitHub issue for technical problems 4. Comment on the issue you're working on if you need guidance -Remember that all contributions, including documentation improvements, bug reports, and feature requests, are valuable to the project. \ No newline at end of file +Remember that all contributions, including documentation improvements, bug reports, and feature requests, are valuable to the project. diff --git a/Readme.md b/Readme.md index d0e4dbba6d3..89e7e24bd32 100644 --- a/Readme.md +++ b/Readme.md @@ -12,22 +12,35 @@ This is a GCC codegen for rustc, which means it can be loaded by the existing ru The primary goal of this project is to be able to compile Rust code on platforms unsupported by LLVM. A secondary goal is to check if using the gcc backend will provide any run-time speed improvement for the programs compiled using rustc. -### Dependencies - -**rustup:** Follow the instructions on the official [website](https://www.rust-lang.org/tools/install) - -**DejaGnu:** Consider to install DejaGnu which is necessary for running the libgccjit test suite. [website](https://www.gnu.org/software/dejagnu/#downloading) - - +## Getting Started -## Building +Note: **This requires a patched libgccjit in order to work. +You need to use my [fork of gcc](https://github.com/antoyo/gcc) which already includes these patches.** -**This requires a patched libgccjit in order to work. -You need to use my [fork of gcc](https://github.com/rust-lang/gcc) which already includes these patches.** - -```bash -$ cp config.example.toml config.toml -``` +### Dependencies + - rustup: follow instructions on the [official website](https://rustup.rs) + - consider to install DejaGnu which is necessary for running the libgccjit test suite. [website](https://www.gnu.org/software/dejagnu/#downloading) + - additional packages: `flex`, `libmpfr-dev`, `libgmp-dev`, `libmpc3`, `libmpc-dev` + +### Quick start +1. Clone and configure the repository: + ```bash + git clone https://github.com/rust-lang/rust_codegen_gcc + cd rust_codegen_gcc + cp config.example.toml config.toml + ``` + +2. Build and test: + ```bash + ./y.sh prepare # downloads and patches sysroot + ./y.sh build --sysroot --release + + # Verify setup with a simple test + ./y.sh cargo build --manifest-path tests/hello-world/Cargo.toml + + # Run full test suite (expect ~100 failing UI tests) + ./y.sh test --release + ``` If don't need to test GCC patches you wrote in our GCC fork, then the default configuration should be all you need. You can update the `rustc_codegen_gcc` without worrying about GCC. @@ -40,7 +53,7 @@ to do a few more things. To build it (most of these instructions come from [here](https://gcc.gnu.org/onlinedocs/jit/internals/index.html), so don't hesitate to take a look there if you encounter an issue): ```bash -$ git clone https://github.com/rust-lang/gcc +$ git clone https://github.com/antoyo/gcc $ sudo apt install flex libmpfr-dev libgmp-dev libmpc3 libmpc-dev $ mkdir gcc-build gcc-install $ cd gcc-build