Conversation
📝 WalkthroughWalkthroughThe GitHub Actions workflow for Rust projects has been updated to include the installation and configuration of the mold linker on Linux environments, specifically when running on the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/rust.yml(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (13)
- GitHub Check: test-snapshot-operations-s3-minio
- GitHub Check: test-shard-snapshot-api-s3-minio
- GitHub Check: test-low-resources
- GitHub Check: Basic TLS/HTTPS tests
- GitHub Check: test-consistency
- GitHub Check: rust-tests (macos-latest)
- GitHub Check: test-consensus-compose
- GitHub Check: rust-tests (windows-latest)
- GitHub Check: integration-tests-consensus
- GitHub Check: rust-tests (ubuntu-latest)
- GitHub Check: integration-tests
- GitHub Check: lint
- GitHub Check: storage-compat-test
| - name: Install mold | ||
| uses: rui314/setup-mold@v1 |
There was a problem hiding this comment.
Condition the mold installation to Linux only
The setup-mold action currently runs on all runners (macOS/Windows included), but it only supports Linux. This will cause the workflow to fail on non-Linux OSes. Add a step-level filter to restrict installation to Ubuntu:
- - name: Install mold
- uses: rui314/setup-mold@v1
+ - name: Install mold (Linux only)
+ if: matrix.os == 'ubuntu-latest'
+ uses: rui314/setup-mold@v1📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - name: Install mold | |
| uses: rui314/setup-mold@v1 | |
| - name: Install mold (Linux only) | |
| if: matrix.os == 'ubuntu-latest' | |
| uses: rui314/setup-mold@v1 |
| run: | | ||
| if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then | ||
| mkdir .cargo | ||
| echo "[target.x86_64-unknown-linux-gnu]" >> .cargo/config.toml | ||
| echo "linker = \"clang\"" >> .cargo/config.toml | ||
| echo "rustflags = [\"-C\", \"link-arg=-fuse-ld=/usr/local/bin/mold\"]" >> .cargo/config.toml | ||
| fi | ||
| shell: bash |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Simplify mold configuration and directory handling
Rather than embedding the OS check in the script, move it to the step level. Also use mkdir -p to avoid errors if .cargo already exists, and switch to a here-document for clearer, atomic file writes:
- - name: Enable mold on Linux
- run: |
- if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
- mkdir .cargo
- echo "[target.x86_64-unknown-linux-gnu]" >> .cargo/config.toml
- echo "linker = \"clang\"" >> .cargo/config.toml
- echo "rustflags = [\"-C\", \"link-arg=-fuse-ld=/usr/local/bin/mold\"]" >> .cargo/config.toml
- fi
- shell: bash
+ - name: Configure mold linker (Linux only)
+ if: matrix.os == 'ubuntu-latest'
+ run: |
+ mkdir -p .cargo
+ cat << 'EOF' > .cargo/config.toml
+ [target.x86_64-unknown-linux-gnu]
+ linker = "clang"
+ rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"]
+ EOF
+ shell: bash📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| run: | | |
| if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then | |
| mkdir .cargo | |
| echo "[target.x86_64-unknown-linux-gnu]" >> .cargo/config.toml | |
| echo "linker = \"clang\"" >> .cargo/config.toml | |
| echo "rustflags = [\"-C\", \"link-arg=-fuse-ld=/usr/local/bin/mold\"]" >> .cargo/config.toml | |
| fi | |
| shell: bash | |
| - name: Configure mold linker (Linux only) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| mkdir -p .cargo | |
| cat << 'EOF' > .cargo/config.toml | |
| [target.x86_64-unknown-linux-gnu] | |
| linker = "clang" | |
| rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"] | |
| EOF | |
| shell: bash |
|
🤞 |
|
acceptance criteria: 10 consecutive green runs for |


This step often fails for Linux with
This PR uses
moldfor linking as it fixed the same issue on Crasher qdrant/crasher#17