cancel
Showing results for 
Search instead for 
Did you mean: 

clang-tidy fails to process project

I was able to successfully build a TouchGFX demo project for a development board with clang+cmake using STM32CubeMX and STM32Cube plugin for VSCode. Although it required tweaking as it didn't work out of the box.
Before ST officially supported clang I was able to build a simple blinky project using clang for arm and cmake and then analyze the code using clang-tidy. Now I want to use clang-tidy on the project, but I get several errors

If I use clang-tidy from clang 1.19.5 I get the following issues:

PS C:\LLVM_19.1.5\bin> ./clang-tidy.exe -p C:\TouchGFXProjects\MyApplication_24\build\Debug C:\TouchGFXProjects\MyApplication_24\Core\Src\main.c
21 errors generated.
Error while processing C:\TouchGFXProjects\MyApplication_24\Core\Src\main.c.
error: too many errors emitted, stopping now [clang-diagnostic-error]
error: unknown argument: '--multi-lib-config=C:\ST\STM32CubeCLT_1.19.0\st-arm-clang/multilib.gnu_tools_for_stm32.yaml' [clang-diagnostic-error]
C:/TouchGFXProjects/MyApplication_24/cmake/stm32cubemx/../../Drivers/CMSIS/Include\cmsis_compiler.h:278:4: error: Unknown compiler. [clang-diagnostic-error]
278 | #error Unknown compiler.
| ^
C:/TouchGFXProjects/MyApplication_24/cmake/stm32cubemx/../../Drivers/CMSIS/Include\core_cm7.h:1871:1: error: unknown type name '__STATIC_INLINE' [clang-diagnostic-error]
1871 | __STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup)

Same for C:\LLVM_19.1.6 and C:\LLVM_21.1.4

And if I use clang-tidy from stm32cube\bundles\st-arm-clang\19.1.6+st.9:

.\starm-clang-tidy.exe -p C:\TouchGFXProjects\MyApplication_24\build\Debug C:\TouchGFXProjects\MyApplication_24\Core\Src\main.c
Error while processing C:/TouchGFXProjects/MyApplication_24/Core/Src/main.c.
error: unknown target triple 'unknown' [clang-diagnostic-error]
error: unsupported option '-mcpu=' for target '' [clang-diagnostic-error]
error: unsupported option '-mfloat-abi=' for target '' [clang-diagnostic-error]
error: unsupported option '-mfpu=' for target '' [clang-diagnostic-error]
warning: argument unused during compilation: '--gcc-toolchain=C:\ST\STM32CubeCLT_1.19.0\GNU-tools-for-STM32\bin/..' [clang-diagnostic-unused-command-line-argument]
warning: argument unused during compilation: '--multi-lib-config=C:\ST\STM32CubeCLT_1.19.0\st-arm-clang/multilib.gnu_tools_for_stm32.yaml' [clang-diagnostic-unused-command-line-argument]
Found compiler error(s).

And the same for clang-tidy from C:\ST\STM32CubeCLT_1.19.0\st-arm-clang\bin

Strangely I could not find the release of clang for arm 19.1.6 on github.  https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/tags What version does ST base it on?

 

Reference: https://community.st.com/t5/stm32-mcus-touchgfx-and-gui/help-with-building-stm32h735-demo-project-with-clang/m-p/853892

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.
0 REPLIES 0