clangd assumes compiler target is 'x86_64-pc-windows-msvc' for .cpp files
Hi!
I have set up a project for the STM32H523RET6 using the following setup:
CubeMX: 6.15.0
STM32 vscode extension: 3.5.1
The project is configured to use starm-clang and starm-clang++ and the STARM_PICOLIBC toolchain
I have created a .cpp file () that i added to my build and updated my CMakeLists.txt with the following:
# Setup compiler settings
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
...
enable_language(C CXX ASM)
...
# Add sources to executable
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
Core/Src/myclass.cpp
# Add user sources here
)
When building the project, it compiles fine, but clangd reports the following problem:
nsupported option '-mcpu=' for target 'x86_64-pc-windows-msvc'clang(drv_unsupported_opt_for_target)
Unsupported option '-mfpu=' for target 'x86_64-pc-windows-msvc'clang(drv_unsupported_opt_for_target)
Unsupported option '-mfloat-abi=' for target 'x86_64-pc-windows-msvc'clang(drv_unsupported_opt_for_target)
Is this a known issue?
For reference (or anyone having a similar issue) i managed to temporarily fix the issue by explicitly setting the target for clangd by changing the .clangd file from
CompileFlags:
Add:
- '-ferror-limit=0'
- '-Wno-implicit-int'
CompilationDatabase: build/Debug
Diagnostics:
Suppress:
- unused-includes
- unknown_typename
- unknown_typename_suggest
- typename_requires_specqualto
CompileFlags:
Add:
- '-ferror-limit=0'
- '-Wno-implicit-int'
- '-target'
- 'thumbv8m.main-st-none-eabihf'
- '-mfpu=fpv4-sp-d16'
- '-fno-exceptions'
- '-fno-rtti'
CompilationDatabase: build/Debug
Diagnostics:
Suppress:
- unused-includes
- unknown_typename
- unknown_typename_suggest
- typename_requires_specqual
