Skip to content

ci: use mold for Linux Rust builds#238

Merged
ScriptedAlchemy merged 6 commits into
masterfrom
codex/linux-ci-mold-linker
Jul 3, 2026
Merged

ci: use mold for Linux Rust builds#238
ScriptedAlchemy merged 6 commits into
masterfrom
codex/linux-ci-mold-linker

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a reusable Linux mold setup action for Rust CI jobs that run inside the checked-out PR branch.
  • Install mold through the official rui314/setup-mold@v1 action instead of apt, then configure Cargo/Rust with RUSTFLAGS=-C link-arg=-fuse-ld=mold.
  • Configure stable/beta Linux release builds with the same official setup action plus explicit Rust linker flags.

Motivation

TraceDecay's Rust build spends enough time in heavy native/link phases that Linux builds were worth benchmarking against mold, especially since Windows already uses lld-link.

Official mold sources recommend this path: the mold README links to “our setup-mold GitHub Action,” and that action is published under the same rui314 owner as rui314/mold.

Local clean debug binary benchmark on this machine:

  • default linker: 2:28.61 wall clock
  • clang -fuse-ld=mold: 1:51.26 wall clock
  • official-action-compatible setup with only RUSTFLAGS=-C link-arg=-fuse-ld=mold: 1:53.68 wall clock

The mold build's binary included mold 2.30.0 (compatible with GNU ld) in .comment, confirming the intended linker path was actually used.

GitHub Actions evidence is more mixed. The first PR run was slower on Linux jobs because changing linker env caused cold Rust target-cache behavior. After rerunning Test Linux warm on the same branch/run, it was essentially neutral rather than faster:

  • Warm Test Linux: 2:58 vs recent pre-mold master median 2:56
  • Warm Test Linux / Run tests step: 2:15 vs recent pre-mold median 2:10
  • Warm Clippy: 1:58 vs recent pre-mold median 1:42, but the actual Run blocking Clippy policy step was identical at 1:15; mold setup/cache overhead explains the job-level delta
  • Warm Dashboard: 3:35 vs recent pre-mold median 3:28
  • Warm Hermes integration: 2:13 vs recent pre-mold median 1:53, while the actual Build tracedecay binary step was slightly faster at 1:08 vs 1:10

Swatinem/rust-cache already includes compiler env such as RUSTFLAGS in its cache key, so this PR keeps the existing shared keys and lets the cache action separate artifacts by its built-in Rust environment hash instead of adding an extra mold-specific suffix.

Changes

  • .github/actions/setup-linux-mold/action.yml delegates installation to rui314/setup-mold@v1 and exports the Rust linker flag.
  • .github/workflows/ci.yml uses the local action for Linux Rust test, clippy, dashboard, and Hermes jobs.
  • .github/workflows/release-plz.yml uses the local action for Ubuntu release-plz jobs.
  • .github/workflows/release.yml and .github/workflows/release-beta.yml use rui314/setup-mold@v1 plus explicit Rust linker flags for Linux release matrices.

Test plan

  • actionlint .github/workflows/ci.yml .github/workflows/release.yml .github/workflows/release-beta.yml .github/workflows/release-plz.yml
  • git diff --check
  • RUSTFLAGS="-C link-arg=-fuse-ld=mold" CARGO_INCREMENTAL=0 CARGO_PROFILE_DEV_DEBUG=0 cargo build --bin tracedecay --locked
  • readelf -p .comment /scratch/cargo-target/linux-ci-mold-linker_-7759b4054875/debug/tracedecay | rg -i 'mold|LLVM|GCC'
  • Previous GitHub CI run on commit 51c1ac1 passed
  • Warm-cache rerun of Test Linux on the same run passed in 2:58
  • GitHub CI run after switching installation to rui314/setup-mold@v1

Checklist

  • CHANGELOG.md updated (N/A: CI-only change)
  • No secrets, credentials, or .env files included
  • Breaking changes documented (N/A: no runtime/API change)

@changeset-bot

changeset-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f415876

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ScriptedAlchemy ScriptedAlchemy force-pushed the codex/linux-ci-mold-linker branch 2 times, most recently from 51c1ac1 to ddce4f6 Compare July 2, 2026 21:59
@ScriptedAlchemy ScriptedAlchemy force-pushed the codex/linux-ci-mold-linker branch from ddce4f6 to b885a3d Compare July 2, 2026 22:13
@ScriptedAlchemy ScriptedAlchemy marked this pull request as ready for review July 3, 2026 01:57

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be31307442

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/release.yml Outdated
ScriptedAlchemy and others added 3 commits July 3, 2026 02:14
GCC only accepts -fuse-ld=mold from GCC 12 onward, so the RUSTFLAGS
approach would fail at link time on the ubuntu-22.04 release runners
(GCC 11) — paths that never run on PR CI. make-default symlinks
/usr/bin/ld to mold, which works on any GCC, keeps RUSTFLAGS and
rust-cache keys untouched, and lets release.yml reuse the composite
action instead of an inline copy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
release.yml can be dispatched with a release_tag whose checkout predates
the local composite action, which would fail to resolve. The remote
setup-mold action resolves at any checkout.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ScriptedAlchemy ScriptedAlchemy merged commit 31e421f into master Jul 3, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant