Pigweed Toolchain#

Pigweed Toolchain is a Clang/LLVM-based toolchain distribution tailored for embedded and baremetal software development. Rather than relying on fragmented, vendor-specific GNU toolchain forks, Pigweed provides a unified LLVM distribution that cross-compiles for many microcontroller architectures from Linux, macOS, and Windows hosts.

The distribution is built from upstream LLVM and shared with other large systems projects: the same CIPD packages that Pigweed consumes are the Clang packages produced and used by the Fuchsia project. All of upstream Pigweed is built and tested with it continuously.

Benefits#

  • Unified cross-compilation: Target Arm Cortex-M, Arm Cortex-A, RISC-V, and host builds from a single hermetic compiler installation across Linux, macOS, and Windows.

  • Modern C++ and tooling: Use C++20/23 along with clangd, clang-tidy, and the Clang Static Analyzer out of the box.

  • Modular, permissively licensed runtimes: Ships with compiler-rt, LLVM libc, and configurable libc++ under Apache 2.0 with LLVM Exceptions.

  • Aggressive size optimization: Link-Time Optimization (LTO/FatLTO), Identical Code Folding (--icf=all), Profile-Guided Optimization (PGO), and ML-Guided Optimization (MLGO) keep flash and SRAM footprints tight.

  • Hardware verification: Compile-time thread and lifetime safety checks, trapping UBSan, and single-byte source-based code coverage run directly on baremetal targets.

Supported targets and hosts#

Pigweed provides ready-to-use Clang toolchains for Arm Cortex-M (M0, M0+, M3, M4, M7, M33, M55), Arm Cortex-A (A35), 32-bit RISC-V (rv32imc, rv32imac), and host targets across Linux, macOS, and Windows development machines. See Supported targets and hosts for the full support matrix and build-system target names.

Learn more#

Get started

Hermetically integrate Pigweed Toolchain into a Bazel or GN project and run LLVM binary analysis tools.

Get started
Why Clang/LLVM for embedded?

Explore the motivations behind co-evolving upstream LLVM, modular baremetal runtimes, LTO/MLGO size optimizations, and hardware sanitizers.

Why Clang/LLVM for embedded
Supported targets & hosts

Check out-of-the-box target architectures, Bazel and GN toolchain names, and supported development host platforms.

Supported targets and hosts
Migrate from a GNU toolchain

A practical three-stage playbook for migrating an embedded codebase from GCC/newlib/Binutils to Clang/LLVM libc/LLD.

Migrate from a GNU toolchain
Versioning, rolls, & stability

Understand how Pigweed pins tip-of-tree LLVM revisions in Bazel and CIPD, how rolls work, and what stability guarantees apply.

Versioning, rolls, and stability
Status & roadmap

See what is production-ready today and what is on the roadmap across Pigweed Toolchain and upstream LLVM.

Status & roadmap

Talks and community#

Pigweed and LLVM developers participate in industry-wide efforts to advance baremetal support in upstream repositories:

  • LLVM Embedded Toolchains Working Group: A public working group that meets every four weeks to discuss embedded compiler features, runtime designs, and linker enhancements.

  • LLVM Embedded Toolchains Workshop: An annual workshop held in conjunction with the LLVM Developers’ Meeting covering baremetal runtime implementations and migration workflows.

  • GitHub embedded tracking: Baremetal issues and pull requests are tracked in the upstream LLVM repository using the embedded label.

The following presentations from LLVM Developers’ Meetings offer detailed technical discussions on embedded development with LLVM:

  • Modern Embedded Development with LLVM (2024): Presented by Petr Hosek at the 2024 LLVM Developers’ Meeting. Covers the deployment of modular LLVM runtimes (LLVM libc, libc++, compiler-rt) on microcontrollers, multi-target toolchains, and bringing sanitizers and code coverage to baremetal.

  • LLVM Toolchain for Embedded Systems (2023): Presented by Prabhu Karthikeyan Rajasekaran at the 2023 LLVM Developers’ Meeting. Discusses motivations for transitioning embedded projects to Clang/LLD, linker script nuances, binary size considerations, and stack usage tracking.

Support#

File a bug or talk to the Pigweed team on Discord. Toolchain issues, migration questions, and requests for architectures or host platforms that aren’t listed in Supported targets and hosts are all in scope.