Skip to content

Commit 31e421f

Browse files
Merge pull request #238 from ScriptedAlchemy/codex/linux-ci-mold-linker
ci: use mold for Linux Rust builds
2 parents 376c3e5 + f415876 commit 31e421f

5 files changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Setup Linux mold linker
2+
description: Install mold and make it the default linker for Linux Rust builds.
3+
4+
runs:
5+
using: composite
6+
steps:
7+
# make-default symlinks /usr/bin/ld to mold, which works on any GCC.
8+
# Passing -fuse-ld=mold via RUSTFLAGS instead would break on the
9+
# ubuntu-22.04 release runners: GCC only accepts that value from
10+
# GCC 12 onward. It also leaves RUSTFLAGS (and rust-cache keys)
11+
# untouched.
12+
- name: Install mold
13+
if: runner.os == 'Linux'
14+
uses: rui314/setup-mold@v1
15+
with:
16+
mold-version: 2.41.0
17+
make-default: true
18+
19+
- name: Verify mold is the default linker
20+
if: runner.os == 'Linux'
21+
shell: bash
22+
run: |
23+
set -euo pipefail
24+
mold --version
25+
ld --version | head -n 1 | grep -i mold

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ jobs:
7272

7373
- uses: dtolnay/rust-toolchain@stable
7474

75+
- uses: ./.github/actions/setup-linux-mold
76+
7577
- uses: actions/setup-node@v4
7678
with:
7779
node-version: 22
@@ -303,6 +305,9 @@ jobs:
303305
- uses: dtolnay/rust-toolchain@stable
304306
with:
305307
components: clippy
308+
309+
- uses: ./.github/actions/setup-linux-mold
310+
306311
- name: Cache Rust build outputs
307312
uses: Swatinem/rust-cache@v2
308313
with:
@@ -377,6 +382,8 @@ jobs:
377382
378383
- uses: dtolnay/rust-toolchain@stable
379384

385+
- uses: ./.github/actions/setup-linux-mold
386+
380387
- name: Install ast-grep
381388
run: |
382389
npm install --global "@ast-grep/cli@${AST_GREP_VERSION}"
@@ -456,6 +463,8 @@ jobs:
456463

457464
- uses: dtolnay/rust-toolchain@stable
458465

466+
- uses: ./.github/actions/setup-linux-mold
467+
459468
- name: Install ast-grep
460469
run: |
461470
npm install --global "@ast-grep/cli@${AST_GREP_VERSION}"

.github/workflows/release-beta.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ jobs:
6464
with:
6565
targets: ${{ matrix.target }}
6666

67+
- uses: ./.github/actions/setup-linux-mold
68+
6769
- name: Use lld-link
6870
if: runner.os == 'Windows'
6971
shell: pwsh

.github/workflows/release-plz.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
4444
- uses: dtolnay/rust-toolchain@stable
4545

46+
- uses: ./.github/actions/setup-linux-mold
47+
4648
- name: Cache Cargo
4749
uses: actions/cache@v4
4850
with:
@@ -83,6 +85,8 @@ jobs:
8385

8486
- uses: dtolnay/rust-toolchain@stable
8587

88+
- uses: ./.github/actions/setup-linux-mold
89+
8690
- name: Cache Cargo
8791
uses: actions/cache@v4
8892
with:

.github/workflows/release.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ jobs:
7373
with:
7474
targets: ${{ matrix.target }}
7575

76+
# Inline instead of ./.github/actions/setup-linux-mold: this workflow
77+
# can be dispatched with an old release_tag, and the checkout above
78+
# replaces the workspace with that tag, which may predate the local
79+
# action. make-default symlinks ld to mold, which works on this
80+
# runner's GCC 11 (unlike -fuse-ld=mold, which needs GCC 12+).
81+
- name: Install mold
82+
if: runner.os == 'Linux'
83+
uses: rui314/setup-mold@v1
84+
with:
85+
mold-version: 2.41.0
86+
make-default: true
87+
88+
- name: Verify mold is the default linker
89+
if: runner.os == 'Linux'
90+
shell: bash
91+
run: |
92+
set -euo pipefail
93+
mold --version
94+
ld --version | head -n 1 | grep -i mold
95+
7696
- name: Use lld-link
7797
if: runner.os == 'Windows'
7898
shell: pwsh

0 commit comments

Comments
 (0)