A Conan tool package for the GNU GCC Toolchain, providing both native compilation
(gcc, g++) and ARM cross-compilation (arm-none-eabi-gcc). By adding this
tool package to your Conan build profile, your project can leverage GCC for
development across multiple platforms and architectures.
Note
We plan to add additional architectures like risc-v, AVR, xtensa etc.
- Unified toolchain: Single package provides both native GCC and ARM cross-compiler
- Automatic selection: Correct toolchain variant chosen based on target OS/architecture
- Embedded ARM support: Built-in support for ARM Cortex-M microcontrollers
- Native compilation: Full GCC support for Linux and Windows
- Optimized binaries: Native GCC from xpack-dev-tools, ARM cross-compiler from official ARM releases
All binaries are downloaded from official sources:
- Native GCC from xpack-dev-tools
- ARM cross-compiler from ARM GNU Toolchain
| Platform | x86_64 | ARM64 |
|---|---|---|
| Linux | β | β |
| Windows | β | β |
Note
Native compilation (building executables for your host OS) is only supported on Linux and Windows. macOS is not supported for native compilation.
The following platforms can cross-compile for ARM Cortex-M targets:
| Platform | x86_64 | ARM64 |
|---|---|---|
| Linux | β | β |
| macOS | β | β |
| Windows | β | β |
To use the Multiarch GNU Toolchain for your application, install the pre-made
compiler profiles to your local conan2 cache:
conan config install -sf conan/profiles/v1 -tf profiles https://github.com/libhal/multiarch-gnu-toolchain.gitThis provides profiles accessible via -pr gcc-14. These profiles only include
compiler information. You'll need a "target" profile to actually build something.
For native development on your host platform, the gcc-14 profile automatically
detects your OS and architecture:
# Build for your current platform (auto-detected)
conan build demos/cpp -pr:a gcc-14For embedded ARM Cortex-M development:
# Cortex-M4 with hardware floating point
conan build demos/cpp -pr:a gcc-14 -pr cortex-m4f
# Cortex-M7 with double-precision FPU
conan build demos/cpp -pr:a gcc-14 -pr cortex-m7d
# Cortex-M33 with hardware floating point
conan build demos/cpp -pr:a gcc-14 -pr cortex-m33fFor this tool package to work correctly, the toolchain MUST be added as a
dependency using tool_requires in at least one profile.
[settings]
compiler=gcc
compiler.cppstd=23
compiler.libcxx=libstdc++11
compiler.version=14
[tool_requires]
multiarch-gnu-toolchain/14By adding multiarch-gnu-toolchain/14 to your profile, every dependency will
use this toolchain for compilation. The tool package should NOT be directly
added to an application's conanfile.py.
For ARM Cortex-M4 with hardware floating point:
[settings]
arch=cortex-m4f
build_type=Release
os=baremetal
For ARM Cortex-M7 with double-precision FPU:
[settings]
arch=cortex-m7d
build_type=Release
os=baremetal
Install profiles into your local Conan cache:
conan config install -sf conan/profiles/v1 -tf profiles https://github.com/libhal/multiarch-gnu-toolchain.gitOr from a locally cloned repo:
conan config install -sf conan/profiles/v1 -tf profiles .All profiles use libstdc++11 as this is the latest GCC C++ ABI.
When you create the package, it downloads the appropriate compiler variant from official releases based on your build and target settings, then stores it in your local Conan package cache:
# For host platform development (native build)
conan create all --version=14 --build-require
# For ARM Cortex-M cross-compilation
conan create all --version=14 --build-require -pr:h gcc-14 -pr cortex-m4fExample profile options:
[options]
multiarch-gnu-toolchain/*:default_arch=True
multiarch-gnu-toolchain/*:lto=True
multiarch-gnu-toolchain/*:fat_lto=True
multiarch-gnu-toolchain/*:function_sections=True
multiarch-gnu-toolchain/*:data_sections=True
multiarch-gnu-toolchain/*:gc_sections=True
multiarch-gnu-toolchain/*:default_libc=True
Path to a local GCC toolchain directory. If not empty, the recipe will use this path instead of downloading the official toolchain. Useful for custom-built toolchains or alternative binary sources.
conan create all --version 14 -o "*:local_path=/path/to/gcc-toolchain/"Automatically inject appropriate -mcpu and -mfloat-abi flags for the arch
defined in your build target profile.
Examples for ARM Cortex-M:
- For
cortex-m4:-mcpu=cortex-m4-mfloat-abi=soft
- For
cortex-m4f:-mcpu=cortex-m4-mfloat-abi=hard-mfpu=fpv4-sp-d16
Enable Link-Time Optimization with -flto.
Warning
LTO is disabled by default for GCC 14 for ARM embedded targets. ZSTD LTO compression support is enabled for the Linux ARM toolchain but not for macOS. This causes errors when object files built on Linux are linked on macOS:
lto1: fatal error: compiler does not support ZSTD LTO compression
compilation terminated.
Enable -ffat-lto-objects for compatibility with linkers that don't support LTO.
This option is ignored if lto is not enabled.
Enable -ffunction-sections to place each function in its own section for
better garbage collection at link time.
Enable -fdata-sections to place each data item in its own section for better
garbage collection at link time.
Enable garbage collection of unused sections. Uses -Wl,--gc-sections linker
flag.
Inject --specs=nosys.specs to linker arguments. This provides weak stubs for
newlib libc APIs like exit(), kill(), sbrk(), allowing binaries to link
without defining all libc APIs upfront.
Compression level for LTO objects. Accepts 0-19 for zstd or 0-9 for zlib.
The following embedded ARM Cortex-M architectures are fully supported:
- cortex-m0
- cortex-m0plus
- cortex-m1
- cortex-m3
- cortex-m4
- cortex-m4f
- cortex-m7
- cortex-m7f
- cortex-m7d
- cortex-m23
- cortex-m33
- cortex-m33f
- cortex-m35p
- cortex-m35pf
- cortex-m55
- cortex-m85
Note
The architecture names may have trailing characters indicating floating point support:
findicates single precision (32-bit) hard floatdindicates double precision (64-bit) hard float
If you'd like to add support for a new GCC version, follow these instructions
(replace XY.Z with the correct version):
Add the version to /config.yml:
versions:
"14":
folder: "all"
"XY.Z":
folder: "all"Add .github/workflows/XY.Z.yml:
name: π XY.Z Deploy
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
jobs:
deploy:
uses: ./.github/workflows/deploy.yml
with:
version: "XY.Z"
secrets: inheritAdd profile gcc-XY.Z to /conan/profiles/v1/:
{% set detected_os = detect_api.detect_os() %}
{% set detected_arch = detect_api.detect_arch() %}
[settings]
os={{ detected_os }}
arch={{ detected_arch }}
build_type=Release
compiler=gcc
compiler.cppstd=23
compiler.libcxx=libstdc++11
compiler.version=XY
[tool_requires]
multiarch-gnu-toolchain/XY.ZAdd download URLs and SHA256 checksums for native and ARM cross-compiler
binaries in all/conandata.yml:
sources:
"XY.Z":
"native":
"Linux":
"x86_64":
url: ""
sha256: ""
"armv8":
url: ""
sha256: ""
"Windows":
"x86_64":
url: ""
sha256: ""
"arm-none-eabi":
"Linux":
"x86_64":
url: ""
sha256: ""
"armv8":
url: ""
sha256: ""
"Macos":
"x86_64":
url: ""
sha256: ""
"armv8":
url: ""
sha256: ""
"Windows":
"x86_64":
url: ""
sha256: ""# Test native build
conan create all --version=XY.Z --build-require
# Test ARM cross-compilation
conan create all --version=XY.Z --build-require -pr:h gcc-XY.Z -pr cortex-m4fSubmit a PR with title :sparkles: Add support for GCC XY.Z.
The package version represents the major GCC version. For example, version "14" uses GCC 14.2.0 binaries.
Contributions are welcome! Please ensure:
- All tests pass on supported platforms
- Documentation is updated for new features
- Profiles are added for new versions
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.