A GitHub Action that downloads, verifies, and adds a GCC cross-compilation toolchain to PATH. Covers ARM, AArch64, RISC-V, Xtensa (ESP32), AVR, MinGW-w64, and native host GCC, on Linux and Windows runners, plus macOS runners for the bare-metal toolchains (macOS is not tested in CI) — see the support matrix below for exact vendor/platform coverage.
- uses: jmacheta/setup-gcc-toolchain@v2
with:
toolchain: arm-none-eabi
version: "15.2.1-1.1"The toolchain is prepended to PATH, so it takes priority over any pre-installed compiler.
| Input | Required | Default | Description |
|---|---|---|---|
toolchain |
yes | — | Toolchain name (see Supported toolchains) |
vendor |
no | — | Vendor name, e.g. xpack or arm. See Vendor selection. |
version |
no | latest |
Version string, or latest for the newest available |
cache-strategy |
no | remote |
How to cache the toolchain: remote, local, both, or none — see Caching |
local-cache-location |
no* | — (or env var, see Caching) | Directory for the local archive cache. *Required when cache-strategy is local or both |
set-ld-library-path |
no | native only | Prepend the toolchain's lib64/lib to LD_LIBRARY_PATH, so built binaries use its bundled libstdc++/libgcc. Unset, this happens only for native toolchains (empty prefix, e.g. x86_64-gcc): a cross toolchain's lib holds target libraries that would break host programs. Set true or false to decide explicitly. |
Some toolchain names are provided by more than one vendor (e.g. arm-none-eabi is available from both arm and xpack). Without vendor:
- an exact
versionis taken from the vendor that lists it (vendors are searched in database file order); if several vendors list the same version, the action fails and asks forvendor; latestis the highest version across all vendors of that toolchain, so the vendor can change when another vendor releases a higher version. Setvendorwhenever you uselatestwith a toolchain that has several vendors.
- uses: jmacheta/setup-gcc-toolchain@v2
with:
toolchain: arm-none-eabi
vendor: xpack # xPack release
version: "15.2.1-1.1"@v2 is a moving tag, and latest follows the toolchain database bundled with the action version you run, so either can change the compiler between runs. For reproducible builds pin version and vendor, and reference the action by a release tag (@v2.3.0) or a commit SHA.
cache-strategy controls how the toolchain is cached across runs:
remote(default) — caches the downloaded archive withactions/cache, under a key that includes the vendor and the archive's sha256. A restored archive is verified against the database sha256 before it is extracted, like a fresh download; a mismatch falls back to downloading. Works on any runner, including ephemeral GitHub-hosted ones.local— reuses downloaded archives from a directory on the runner's disk instead of re-downloading. Only useful on a persistent self-hosted runner, but skips the network round-trip andactions/cachequota entirely. Requireslocal-cache-location(directly, or viaSETUP_GCC_TOOLCHAIN_LOCAL_CACHE_LOCATION); the checksum from the toolchain database is always re-verified against the on-disk archive, and a mismatch falls back to a fresh download.both— e.g. for a matrix mixing persistent self-hosted and ephemeral hosted runners, where the local cache helps the former and the remote cache is the only option for the latter.none— always download fresh.
local-cache-location sets the directory for the local archive cache, and falls back to the SETUP_GCC_TOOLCHAIN_LOCAL_CACHE_LOCATION env var if omitted — so a self-hosted runner can set its cache path once instead of every workflow repeating it. Safe for concurrent runners sharing the same local disk: archives are written with an atomic rename, and each run copies the archive into its own RUNNER_TEMP before verifying and extracting it, so a later change to the shared file can't slip in. Not guaranteed on a network filesystem (e.g. NFS). The directory is created with mode 0750; restrict it to the runner user(s).
| Output | Description |
|---|---|
toolchain-path |
Absolute path to the toolchain root directory |
cache-hit |
true if the archive was restored from the remote cache (actions/cache) and passed sha256 verification; false for a download, a local cache hit, or a toolchain already installed by an earlier step of the same job |
prefix |
Tool prefix, e.g. aarch64_be-none-linux-gnu-, so ${prefix}gcc is the compiler (empty for x86_64-gcc) |
gcc-version |
Full GCC version from <prefix>gcc -dumpfullversion, e.g. 15.2.1 (empty if the compiler was not found) |
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- id: gcc
uses: jmacheta/setup-gcc-toolchain@v2
with:
toolchain: aarch64_be-none-linux-gnu
- run: echo "GCC ${{ steps.gcc.outputs.gcc-version }}"
- run: cmake -B build -DCMAKE_C_COMPILER=${{ steps.gcc.outputs.prefix }}gcc- Unknown toolchain, vendor or version: the step fails before downloading, listing the toolchains, vendors or versions available on this runner platform.
- Version offered by several vendors: the step fails and asks you to set
vendor. - Checksum mismatch: a corrupt download is deleted and retried (3 attempts); if it still doesn't match the database sha256, the step fails and nothing is installed. A cached archive that doesn't match is discarded and downloaded again. An HTTP 4xx (e.g. a removed upstream file) fails at once, without retries.
- Missing compiler binary: if
<prefix>gccisn't in the archive'sbin/, the action only warns andgcc-versionis empty; a missingbin/directory fails the step. - Unsupported runner platform or
RUNNER_TEMPnot set: the step fails.
The version badges show the highest version of each toolchain across all vendors and platforms; a given vendor or platform may top out lower.
¹ The macOS databases (darwin-x64, darwin-arm64) exist but are not tested in CI.
² x86_64 on x64 runners; on linux-arm64 it is xPack's native AArch64 host GCC, despite the name.
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: jmacheta/setup-gcc-toolchain@v2
with:
toolchain: arm-none-eabi
version: "15.2.1-1.1"
- run: arm-none-eabi-gcc --version
- run: makeversion defaults to latest, so it can be omitted entirely:
- uses: jmacheta/setup-gcc-toolchain@v2
with:
toolchain: riscv-none-elf
cache-strategy: nonejobs:
build:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v7
- uses: jmacheta/setup-gcc-toolchain@v2
with:
toolchain: xtensa-esp-elf
version: "16.1.0_20260609"
- run: xtensa-esp-elf-gcc --versionjobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v7
- uses: jmacheta/setup-gcc-toolchain@v2
with:
toolchain: x86_64-w64-mingw32-ucrt
version: "16.1.0"
- run: x86_64-w64-mingw32-gcc --versionWhen a toolchain is provided by more than one vendor, use the vendor input:
- uses: jmacheta/setup-gcc-toolchain@v2
with:
toolchain: arm-none-eabi
vendor: arm # official ARM Ltd release
version: "14.2.rel1"jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- { name: arm-none-eabi, version: "15.2.1-1.1" }
- { name: riscv-none-elf, version: "15.2.0-1" }
- { name: avr, version: "14.1.0" }
steps:
- uses: actions/checkout@v7
- uses: jmacheta/setup-gcc-toolchain@v2
with:
toolchain: ${{ matrix.toolchain.name }}
version: ${{ matrix.toolchain.version }}
- run: make TOOLCHAIN=${{ matrix.toolchain.name }}New toolchain versions and fixes are welcome: see CONTRIBUTING.md.