Skip to content

Commit 2f7a468

Browse files
authored
Setup mold linker (#6)
Sets up the [mold](https://github.com/rui314/mold) linker, defaulting to v2.31.0 (latest at time of writing).
1 parent ef16979 commit 2f7a468

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

.github/workflows/test.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ permissions:
1313
contents: read
1414

1515
jobs:
16-
test:
16+
registry:
1717
name: Rust ${{ matrix.rust }} using ${{ matrix.registry }}
1818
runs-on: ubuntu-latest
1919
strategy:
@@ -43,3 +43,34 @@ jobs:
4343
- run: cargo init . --bin --name ci
4444
- run: cargo add logging --registry ${{ matrix.registry }}
4545
- run: cargo check
46+
47+
linker:
48+
name: Rust ${{ matrix.rust }} with mold linker
49+
runs-on: ubuntu-latest
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
rust:
54+
- stable
55+
- beta
56+
- nightly
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Set registry name
61+
run: sed -i "s/REGISTRY/wafflehacks/g" .cargo/config.toml
62+
63+
- name: TheHackerApp/setup-rust@main
64+
uses: ./
65+
with:
66+
ssh-private-key: ${{ secrets.SHIPYARD_SSH_KEY }}
67+
token: ${{ secrets.SHIPYARD_TOKEN }}
68+
toolchain: ${{ matrix.rust }}
69+
with-mold: true
70+
71+
- run: cargo init . --bin --name ci
72+
- run: cargo add rand
73+
- run: cargo check
74+
env:
75+
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: clang
76+
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS: -C link-args=-fuse-ld=mold

action.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ inputs:
2323
components:
2424
description: Comma-separated list of components to be additionally installed
2525
required: false
26+
with-mold:
27+
description: Whether to install the mold linker
28+
required: false
29+
default: true
30+
mold-version:
31+
description: Version of the mold linker to install
32+
required: false
33+
default: "2.31.0"
2634

2735
runs:
2836
using: composite
@@ -52,3 +60,16 @@ runs:
5260
run: |
5361
echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" >> $GITHUB_ENV
5462
echo "CARGO_REGISTRY_GLOBAL_CREDENTIAL_PROVIDERS=cargo:token" >> $GITHUB_ENV
63+
64+
- name: Install mold linker
65+
shell: bash
66+
if: inputs.with-mold == 'true'
67+
run: |
68+
wget -qO /tmp/mold.tar.gz https://github.com/rui314/mold/releases/download/v${{ inputs.mold-version }}/mold-${{ inputs.mold-version }}-x86_64-linux.tar.gz; \
69+
sudo tar -xf /tmp/mold.tar.gz -C /usr/local --strip-components 1; \
70+
rm /tmp/mold.tar.gz
71+
72+
- name: Install clang
73+
shell: bash
74+
if: inputs.with-mold == 'true'
75+
run: sudo apt-get install -y clang libclang-dev

0 commit comments

Comments
 (0)