A Conan tool package for the LLVM Toolchain (clang, clang++, lld). By
adding this tool package to your Conan build profile, your project can leverage
the LLVM toolchain for modern C++ development across multiple platforms and
architectures.
- Single cross-compiler: LLVM can target multiple architectures with one toolchain
- Embedded ARM support: Built-in support for ARM Cortex-M microcontrollers using the ARM LLVM Embedded Toolchain
- Modules support: LLVM 20+ includes full C++20 modules support
- Modern C++ standards: Best-in-class support for C++20/23 features
- Better diagnostics: Clear, actionable error messages
- Integrated tooling: Includes clang-tidy, clang-format, and other development tools
This toolchain includes full C++20 modules support out of the box when using
CMake and Ninja (enabled by default via require_cmake and require_ninja options).
To use C++20 modules in your project, use target_sources with the FILE_SET
parameter to specify module interface files (.cppm):
cmake_minimum_required(VERSION 3.40)
project(my_project LANGUAGES CXX)
add_executable(my_app)
target_sources(my_app PUBLIC
FILE_SET CXX_MODULES
TYPE CXX_MODULES
FILES my_module.cppm # Module interface files
PRIVATE
main.cpp # Regular source files
other_source.cpp
)Key points:
- Module interface files (
.cppm) must be listed underFILE_SET CXX_MODULES - Regular source files (
.cpp) are listed underPRIVATE - CMake automatically handles module dependency scanning via
clang-scan-deps - Works seamlessly with both host platforms and ARM Cortex-M targets
See demos/cpp-modules/ for a complete working example.
All binaries are downloaded from official sources:
- Upstream LLVM from LLVM GitHub Releases
- ARM Cortex-M targets from ARM LLVM Embedded Toolchain
| Platform | x86_64 | ARM64 |
|---|---|---|
| Linux | โ | โ |
| macOS | โ | โ |
| Windows | โ | โ |
Important
This package uses version "20" to represent the most recent official releases from both upstream LLVM and the ARM LLVM Embedded Toolchain. However, the exact version numbers differ:
- Upstream LLVM: Version 20.1.8 (for host platforms and non-Cortex-M targets)
- ARM Embedded Toolchain: Version 20.1.0 (for ARM Cortex-M baremetal targets)
Both versions are the latest official releases available at the time of packaging. The package automatically selects the appropriate variant based on your target architecture.
To use the LLVM 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/llvm-toolchain.gitThis provides profiles accessible via -pr llvm-20. These profiles only
include compiler information. You'll need a "target" profile to actually build
something.
For native development on your host platform:
# x86_64 Linux
conan build . -pr llvm-20 -pr linux_x86_64
# ARM64 Linux
conan build . -pr llvm-20 -pr linux_arm
# ARM64 macOS
conan build . -pr llvm-20 -pr macos_arm
# x86_64 Windows
conan build . -pr llvm-20 -pr windows_x86_64For embedded ARM Cortex-M development (cross-compilation):
# Cortex-M4 with hardware floating point
conan build . -pr llvm-20 -pr cortex-m4f
# Cortex-M7 with double-precision FPU
conan build . -pr llvm-20 -pr cortex-m7d
# Cortex-M33 with hardware floating point
conan build . -pr llvm-20 -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=clang
compiler.cppstd=23
compiler.libcxx=libc++
compiler.version=20
[tool_requires]
llvm-toolchain/20By adding llvm-toolchain/20 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.
Note that the profile above is missing the following settings:
osbuild_typearch
For a Release build on an M1 (ARM CPU) Mac:
[settings]
arch=armv8
build_type=Release
os=Macos
For x86_64 Linux:
[settings]
arch=x86_64
build_type=Release
os=Linux
For x86_64 Windows:
[settings]
arch=x86_64
build_type=Release
os=Windows
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/llvm-toolchain.gitOr from a locally cloned repo:
conan config install -sf conan/profiles/v1 -tf profiles .Profiles use libc++ as the standard library (LLVM's C++ standard library implementation).
When you create the package, it downloads the appropriate compiler variant from the official releases based on your build and target settings, then stores it in your local Conan package cache:
# For host platform development
conan create . --version 20
# For ARM Cortex-M cross-compilation (downloads ARM Embedded variant)
conan create . -pr:b default -pr:h cortex-m4f -pr:h llvm-20 --version 20 --build-requireExample profile options:
[options]
llvm-toolchain/*:default_arch=True
llvm-toolchain/*:default_linker_script=True
llvm-toolchain/*:lto=True
llvm-toolchain/*:data_sections=True
llvm-toolchain/*:function_sections=True
llvm-toolchain/*:gc_sections=True
llvm-toolchain/*:require_cmake=True
llvm-toolchain/*:require_ninja=True
Automatically inject appropriate -target, -mcpu, and -mfloat-abi flags for
the arch defined in your build target profile.
Examples for ARM Cortex-M:
- For
cortex-m4:-target armv7em-none-eabi-mcpu=cortex-m4-mfloat-abi=soft
- For
cortex-m4f:-target armv7em-none-eabihf-mcpu=cortex-m4-mfloat-abi=hard-mfpu=fpv4-sp-d16
Automatically specify the default linker script (picolibcpp.ld) to allow
projects without a linker script to link without error. If you specify your own
linker script(s) via the -T argument, the default linker script will be
ignored and your supplied linker script(s) will be used.
Note
Disabling this flag is not necessary when building applications with custom linker scripts. Only use this if you have multiple custom linker scripts and want to override the default linker script supplied by this toolchain.
Enable Link-Time Optimization with -flto.
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 --gc-sections linker flag for garbage collection of unused sections.
Automatically add cmake/[^4.1.2] as a transitive build requirement. This ensures
that CMake is available for building projects that use the LLVM toolchain.
When enabled, the toolchain will also set the following CMake variables (when
require_ninja is also enabled):
CMAKE_CXX_SCAN_FOR_MODULES: Enables C++20 modules supportCMAKE_EXPERIMENTAL_EXPORT_PACKAGE_DEPENDENCIES: Enables experimental package dependency export features
Users can disable this option in build profiles if they want to manage CMake versions themselves.
Automatically add ninja/[^1.13.1] as a transitive build requirement and
configure CMake to use Ninja as the generator.
When enabled, the toolchain will set:
- CMake generator to "Ninja" via
tools.cmake.cmaketoolchain:generator
Users can disable this option in build profiles if they want to use a different build system or manage Ninja versions themselves.
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
These targets use the ARM LLVM Embedded Toolchain, which is specifically optimized for bare-metal ARM Cortex-M development and includes optimized C/C++ libraries for embedded systems.
Support for additional architectures (RISC-V, AVR, etc.) is planned. These will use the upstream LLVM toolchain. Contributions are welcome!
The "Release" version represents the version of the conanfile.py and its
conandata.yml. Versions follow SEMVER 2.
- Patch version increments if:
- A non-feature change or fix has been applied to the conan recipe
- Minor version increments if:
- A new option is made available via the recipe
- New versions of LLVM made available within
conandata.yml
- Major number increments if:
- An option is removed
- Command line arguments change in such a way as to not be a bug fix but to seriously change the semantics of a program
- A toolchain file is:
- Removed
- Added and enforced for all downstream users that meaningfully changes the semantics or compilation of a program
The package version (e.g., "20") represents a collection of related LLVM toolchain releases:
- Upstream LLVM: Used for host platforms (Linux, macOS, Windows) and non-Cortex-M cross-compilation targets. Currently version 20.1.8.
- ARM Embedded Toolchain: Used for ARM Cortex-M baremetal targets. Currently version 20.1.0.
While these version numbers don't match exactly, both represent the latest official releases from their respective sources. The package automatically selects the appropriate variant based on your target architecture, ensuring you always get the correct toolchain for your build.
To add support for a new LLVM version to this package, follow these steps:
Download the official LLVM prebuilt binaries from the LLVM GitHub Releases page. Look for the release tagged as llvmorg-X.X.X and download the appropriate archives for each supported platform:
- Linux x86_64:
LLVM-X.X.X-Linux-X64.tar.xz - Linux ARM64:
LLVM-X.X.X-Linux-ARM64.tar.xz - macOS ARM64:
LLVM-X.X.X-macOS-ARM64.tar.xz - Windows x86_64:
clang+llvm-X.X.X-x86_64-pc-windows-msvc.tar.xz - Windows ARM64:
clang+llvm-X.X.X-aarch64-pc-windows-msvc.tar.xz(if available)
For ARM Cortex-M support, download from the ARM Toolchain Releases:
- Linux x86_64:
ATfE-X.X.X-Linux-x86_64.tar.xz - Linux ARM64:
ATfE-X.X.X-Linux-AArch64.tar.xz - macOS Universal:
ATfE-X.X.X-Darwin-universal.dmg - Windows x86_64:
ATfE-X.X.X-Windows-x86_64.zip
Note
Not all platforms may be available for every LLVM version. Only download what's officially provided.
Calculate the SHA256 checksums for all downloaded archives:
cd /path/to/downloaded/archives
shasum -a 256 *.tar.xz *.dmg *.zipSave these checksums - you'll need them for the next step.
Add a new version entry to all/conandata.yml with the URLs and SHA256 checksums:
sources:
"X":
"upstream":
"Linux":
"x86_64":
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-X.X.X/LLVM-X.X.X-Linux-X64.tar.xz"
sha256: "<checksum>"
"armv8":
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-X.X.X/LLVM-X.X.X-Linux-ARM64.tar.xz"
sha256: "<checksum>"
"Macos":
"armv8":
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-X.X.X/LLVM-X.X.X-macOS-ARM64.tar.xz"
sha256: "<checksum>"
"Windows":
"x86_64":
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-X.X.X/clang+llvm-X.X.X-x86_64-pc-windows-msvc.tar.xz"
sha256: "<checksum>"
"arm-embedded":
"Linux":
"x86_64":
url: "https://github.com/arm/arm-toolchain/releases/download/release-X.X.X-ATfE/ATfE-X.X.X-Linux-x86_64.tar.xz"
sha256: "<checksum>"
"armv8":
url: "https://github.com/arm/arm-toolchain/releases/download/release-X.X.X-ATfE/ATfE-X.X.X-Linux-AArch64.tar.xz"
sha256: "<checksum>"
"Macos":
"armv8":
url: "https://github.com/arm/arm-toolchain/releases/download/release-X.X.X-ATfE/ATfE-X.X.X-Darwin-universal.dmg"
sha256: "<checksum>"
"x86_64":
url: "https://github.com/arm/arm-toolchain/releases/download/release-X.X.X-ATfE/ATfE-X.X.X-Darwin-universal.dmg"
sha256: "<checksum>"
"Windows":
"x86_64":
url: "https://github.com/arm/arm-toolchain/releases/download/release-X.X.X-ATfE/ATfE-X.X.X-Windows-x86_64.zip"
sha256: "<checksum>"Only include platforms that have official prebuilt binaries available.
Add the new version to the Supported Versions & Host Platforms section in this README. Be transparent about any version differences between upstream LLVM and the ARM Embedded Toolchain.
Build and test the package locally for both host and ARM Cortex-M targets:
# Test host platform build
conan create all --version X
# Test ARM Cortex-M cross-compilation
conan create all -pr:b default -pr:h cortex-m4f -pr:h llvm-X --version X --build-requireThis downloads the binaries, verifies checksums, and creates the package.
Install the toolchain profiles and build the demo application:
# Install toolchain profiles
conan config install -tf profiles/ -sf conan/profiles/v1/ .
# Build the demo for host platform
conan build demo -pr llvm-X -pr linux_x86_64 --build=missing
# Build the demo for ARM Cortex-M (cross-compilation)
conan build demo -pr llvm-X -pr cortex-m4f --build=missingNote
Replace linux_x86_64 and cortex-m4f with your platform's profile.
Available profiles are in the conan/profiles/v1/ directory.
Once you've verified everything works:
- Commit your changes to
all/conandata.ymlandREADME.md - Submit a pull request with a clear description of the version being added
- Include any platform-specific notes or limitations
- Note any version mismatches between upstream LLVM and ARM Embedded Toolchain