Skip to main content
ST Employee
July 8, 2025

STM32Cube further facilitates code development with Clang/LLVM support

  • July 8, 2025
  • 20 replies
  • 25321 views

Clang/LLVM toolchain project overview

For over a decade ST has offered GNU tools for STM32 as the free, reference toolchain when developing STM32 applications. It is well supported across the complete STM32Cube ecosystem and will continue to be maintained by ST.

The Clang/LLVM toolchain will over time offer STM32 developers better code density and execution speed. This release is a first step on the journey towards better toolchain performance and increased STM32Cube ecosystem integration. The toolchain will be supported within STM32CubeMX and with STM32Cube for Visual Studio Code.

This release provides a first version of the ST Arm Clang toolchain built on the Arm LLVM source tree. It allows early adopters to try a toolchain with a similar performance compared to today’s GCC. It offers more sanity checkers, more optimized C libraries, while compiler benchmark figures will come later.

Further to this initial release, developers can expect two additional steps:

  • Feedback collection  
    Early adopters will be provided the opportunity to share feedback, allowing ST to finetune the toolchain and ensure its level of integration across the STM32Cube ecosystem meets expectations. 
  • Toolchain optimization 
    ST will adjust the toolchain with the aim to improve code density and execution speed.

Embracing a step-by-step approach ensures that we set priorities in the development phase, in accordance with developer feedback. The ST Arm Clang flavor will soon provide example projects, and STM32CubeMX and STM32Cube for Visual Studio Code will help STM32 developers get started in the meantime. 

What the ST Arm Clang toolchain offers

ST Arm Clang is a new C/C++ toolchain for STM32 development, which is built on the modern LLVM compiler infrastructure and the Arm Toolchain for Embedded.

This new LLVM-based toolchain provides developers with a more efficient, flexible, and future-proof development environment while maintaining compatibility with existing projects.

ST Arm Clang is designed as a drop-in replacement for the GNU tools for STM32, minimizing disruption for developers transitioning to it. However, several minor incompatibilities or divergent features may exist due to the differences in the underlying infrastructure. To ease this transition, we provide two versions of the toolchain:

  • Hybrid toolchain: only the C/C++ LLVM Clang compiler and the integrated assembler are used to compile the code into object files (local applications, HAL, etc.). The final binary is built using the tools and libraries from the existing GNU tools for STM32 (GNU Binutils linker, C/C++ libraries, and runtime). This hybrid version is ideal for developers looking to test or leverage Clang's compilation while retaining the familiar GNU linking and runtime environment. Both toolchains (Clang and GCC) should be installed on your system, and link-time optimization (LTO) is not available in this mode.
  • Full LLVM toolchain: this version offers the complete long-term LLVM-based solution (Clang compiler, LLVM linker and runtime) with updated libraries, such as Picolibc or LLVM libc++. It benefits from the combined effort from the LLVM community, as well as Arm and ST research and development teams to reach optimal support, performance, and code-size on STM32 devices. The toolchain offers two distinct C library implementations, allowing developers to choose based on their project priorities or device resources: Newlib for performance and Picolibc for code size.

STM32CubeMX support 

The STM32CubeMX version 6.15 introduces support for ST Arm Clang. More specifically, STM32CubeMX generates projects for the hybrid flavor of the ST Arm Clang toolchain. This will allow STM32 developers to quickly try their existing GCC projects with ST Arm Clang toolchain without having to write a new linker script or consider incompatibilities between Newlib and Picolibc. 

Selecting the combination of CMake and ST Arm Clang will create a project targeting the hybrid toolchain:Picture2.png

If users wish to switch from the hybrid to the full LLVM flavor, they can do so inside STM32Cube for Visual Studio Code , following the explanations below.

STM32Cube for Visual Studio Code

Developers can choose between two options to start a project within the STM32Cube ecosystem.

  1. Use STM32CubeMX to generate a configurable project
  2. Use STM32Cube for Visual Studio Code to generate an empty project

This tutorial is based on the assumption that a project was created with STM32CubeMX as shown in the previous chapter.

How to import an STM32CubeMX project and initiate the Visual Studio Code environment

 Inside STM32Cube for Visual Studio Code, open the folder containing the project generated with STM32CubeMX.

Picture3.png

 Picture4.png

Select the folder where STM32CubeMX generated the project.

Allow STM32Cube for Visual Studio Code to load the STM32 extension. You will be asked to configure the project and an STM32Cube project, and select Yes.

Picture5.png

Visual Studio Code will read the project metadata and detect whether the ST Arm Clang toolchain is installed or not.

If this is the first time that a project is created targeting this new toolchain, the environment will automatically download, install, and activate this toolchain for this project. The download size is ~700 Mbytes and the installation footprint is 2.5 Gbytes.

The Visual Studio Code environment is not reconfigured to use ST Arm Clang globally. The toolchain selection and management of environmental paths are managed locally inside Visual Studio Code and can be unique to each project.

Building the project and analyzing the results

When the installation of ST Arm Clang is complete, CMake is invoked to run the configure step on the project.

Picture6.png

The new ST Arm Clang toolchain as can be seen in the CMake/Build output channel.

Click the build button to build your project.

Picture7.png

 

Picture8.png


The result is shown in the output console. A build analyzer is available to give further insights into the build result. Right-click on any map-file and select Open memories analysis.

Understanding the CMake file structure and how to select the toolchain

The CMakePresets.json is using the file starm-clang.cmake as the CMake toolchain file.

Picture9.png

 

This line would point to gcc-arm-none-eabi.cmake if STM32CubeMX was generating this file targeting GCC. STM32CubeMX 6.15 and later versions will generate both gcc-arm-none-eabi.cmake and starm-clang.cmake in parallel to allow developers to switch toolchains from inside the IDE. STM32CubeMX will generate these two files only once and never modify them again.

The accompanying starm-clang.cmake will allow developers to select which C library combination to choose.

Picture11.png

 

By default, the hybrid  version of the ST Arm Clang toolchains is selected since it has the closest compatibility vs the existing GNU tools for STM32. We recommend developers to try building and testing their code with this toolchain. This transitional step will help them become more familiar with this version before using the full LLVM flavor relying on either Newlib or Picolib by switching the value of the variable STARM_TOOLCHAIN_CONFIG as seen above.

The STM32Cube for Visual Studio Code user guide provides additional documentation on ST Arm Clang and additional resources will be added soon based on feedback.

How to use ST Arm Clang with STM32CubeIDE

For the time being, ST Arm Clang is not integrated in the STM32CubeIDE installation package due to its significant size that could impair user experience. However, it will be supported in STM32CubeCLT from the 1.19.0 version. You can follow the steps below to install and set it up for your next project.

How to install STM32CubeCLT

  1. Download STM32CubeCLT from this link:  STM32CubeCLT- STMicroelectronics
  2. Install the package using this document installation-guide-stmicroelectronics.pdf

How to import an STM32CubeMX project and initiate the Visual Studio Code environment 

In STM32CubeIDE, go to File > New > STM32 CMake Project

AmelieACKERMANN_0-1753971934032.png

Since the project has been generated with STM32CubeMX, select “Project with existing CMake sources”.

AmelieACKERMANN_1-1753971984983.png

Name the project and select the folder containing the project generated with the STM32CubeMX.

AmelieACKERMANN_2-1753972030339.png

The project will be imported into the current workspace.

AmelieACKERMANN_3-1753972060456.png

You can now start building your project. The compiler will be detected automatically.

Additional resources

First published on Jul 08, 2025

 

20 replies

lconlcong
Associate II
July 10, 2025

I actually wrote a script before to patch the CubeMX-generated gcc-arm-none-eabi.cmake so I could use Clang for STM32 builds. Looks like that's not really needed anymore with the new STM32Cube support.

But where can I download the standalone ST Arm Clang toolchain? Is there a way to get it as a separate package, kind of like STM32CubeCLT, for CI/CD or automation use?

Explorer
July 15, 2025

Thank you!!!  I was just writing some coroutine code with generic lambdas, and GCC could not figure out how to compile it.  But Clang works great!

Explorer II
July 22, 2025

@Maxime_MARCHETTO Are there any plans to create ST Arm Clang toolchain for Mac OS X environment?

ST Employee
July 25, 2025

@lconlcong The ST Arm Clang toolchain is currently available only in STM32Cube for Visual Studio Code, but it will be included in the upcoming STM32CubeCLT release.

ST Employee
July 25, 2025

@bonemancer Two macOS versions (x86_64 and AArch64) are provided in the STM32Cube for Visual Studio Code bundle manager.

Explorer II
July 26, 2025

@Yvan_R Thanks for fast reply. Will check this on new project within few days.

martinmelkis9
Associate
August 1, 2025

Dear STM team,

What is the roadmap for introducing this toolchain and VS Code support for MPUs, e.g. STM32MP13 devices?


GCsor
Graduate
August 11, 2025

Hi all,

I'm really happy that ST provides a clang compiler with the CLT now. I managed to set up my project to build with clang and it works, but I was no able to set up clang-tidy with my setup.

I have a problem though: If I add CMAKE_CXX_CLANG_TIDY variable to the project, the compiler shows an error about an unknow target triple, and unsupported option about -mcpu and others.

If I call starm-clang-tidy from command line the check works, but I find this a bit inconvenient for running this for all source files. (I also had to manually remove the references of modmap files from the compile_commands.json, but this might be a Ninja issue)

Does anyone have an idea why the cmake setting doesn't work? I think there's something with the HYBRID setup and the multilib detection.

Thanks for any help.

Lead II
August 11, 2025

Will this work with TouchGFX?

And will this fix this bug: https://community.st.com/t5/stm32cubemx-mcus/sysmem-c-build-error-in-clang/td-p/775105

"Kudo posts if you have the same problem and kudo replies if the solution works.Click ""Accept as Solution"" if a reply solved your problem. If no solution was posted please answer with your own."
Jerome B
ST Employee
August 19, 2025

@martinmelkis9, there are currently no plans to bring the Clang/LLVM toolchain for STM32MP products, no plan neither to bring those products support in the STM32Cube for VS Code toolset.

In case you have specific needs there, do not hesitate to share use cases, it can feed our road mapping activities.