Open HTD opened 1 year ago
Are you using a project config or a user config file (https://clangd.llvm.org/config.html#files)? Project config files are scoped to apply only to files in the directory tree of the directory containing the config file.
I don't use any additional config files. The very first file attached is a file named .calangd
and it sits in project's root.
Beside this file, a .vscode/compile_flags.txt
file is used that contains only -I
flags with project include directories. In gcc-arm-none-eabi-10.3-2021.10
directory there is a GNU Toolchain for STM32 version 10.3.1.
I also tested it with the latest release from ARM (12.2.1), and tried the latest clangd
version, that is 15.0.6.
I believe there is no user or system wide configuration file beside that.
As I've seen in output, there are multiple -internal-isystem
entries with Windows and other kits, they appear when --query-driver
argument is used. The exact value of the driver string is in the logs.
I tested it also without --query-drivers
- then ALL system includes was ignored. So - clangd
said it doesn't see string
. With --query-driver
it sees the directory the string
lives in, that is arm-none-eabi\include\c++\12.2.1
(relative to toolchain root), but not arm-none-eabi\include\c++\12.2.1\arm-none-eabi
where bits
directory lives, containing c++config.h
that is reported missing.
Excuse me the different versions given, I just opened the latest toolchain to triple-check where the files are. I triple-checked if the directory names are correct when I was testing both versions. Also - all -isystem
directories are visible from non-system file in my project. The only problem is with the files that are included with -isystem
or -isyswithroot
that are part of the toolchain.
I think the important piece of information is that the files within arm-none-eabi\include\c++\12.2.1
are included correctly, but the ones in arm-none-eabi\include\c++\12.2.1\arm-none-eabi
are not.
One more thing:
I provide: --query-driver=D:\\arm\\gcc-arm-none-eabi-10.3-2021.10\\bin\\arm-none-eabi-g++.exe
.
I get:
V[14:35:34.576] System include extraction: driver clang expanded to C:\Program Files\LLVM\bin\clang.exe
V[14:35:34.576] System include extraction: not allowed driver C:\Program Files\LLVM\bin\clang.exe
Why is that?
I tried specifying the compiler path with forward slashes, backward slashes, executable only without path (I have it added to the system PATH). Nothing works, it seems like it ignores the argument completely, I can provide qwerty
and it behaves the same.
Seems like the -query-driver=
parameter doesn't work.
I tested it again with clangd
in versions 15.0.0, 15.0.3, 15.0.6, 16.0.2. In versions before 16.0.2:
Driver produced command: cc1 -cc1 -triple x86_64-pc-windows-msvc19.35.32215
For the -query-driver=D:\\arm\\gcc-arm-none-eabi-10.3-2021.10\\bin\\arm-none-eabi-g++.exe
argument. Obviously wrong, here's what it should receive:
arm-none-eabi-g++.exe -dumpmachine
arm-none-eabi
arm-none-eabi-g++.exe -dumpversion
10.3.1
arm-none-eabi-g++.exe -print-sysroot
d:\arm\gcc-arm-none-eabi-10.3-2021.10\bin\../arm-none-eabi
< arm-none-eabi-g++.exe -print-multiarch
Since 16.0.2 it says straight it uses other driver than specified. Also doesn't work, no toolchain includes are resolved.
The very first file attached is a file named
.calangd
and it sits in project's root.
Repeating from my last comment:
Project config files are scoped to apply only to files in the directory tree of the directory containing the config file.
Since you reported originally that:
It works perfecly for any file in the project.
It doesn't work for system includes as
or . For those files I get errors like this:
So, if you have a project config file at d:\Source\CodeDog\SWD\Software\SWD-STM32H745I-DISCO\.clangd
That will apply to d:\Source\CodeDog\SWD\Software\SWD-STM32H745I-DISCO\SomeSubdirectory\SomeFile.cpp
(because that's in the directory tree d:\Source\CodeDog\SWD\Software\SWD-STM32H745I-DISCO\
)
It will not apply to d:\source\embedded\gcc-arm-none-eabi-10.3-2021.10\arm-none-eabi\include\c++\10.3.1\string
(because that's not in the directory tree d:\Source\CodeDog\SWD\Software\SWD-STM32H745I-DISCO\
)
To apply to files outside the project directory, configuration needs to go into the user config file.
I have a configuration for compiling my STM32CubeIDE project with clang:
It works perfecly for any file in the project.
It doesn't work for system includes as
<string>
or<utility>
. For those files I get errors like this:If I place
#include <bits/c++config.h>
inside my project, just anywhere, even in a file with no extension - it's OK.It seems like
clangd
sees my include paths, but doesn't apply it to system includes, or doesn't apply it to system includes without extension.Logs
System information
clangd version 12.0.0 Editor/LSP plugin: Visual Studio Code 1.77.3 Operating system: Windows 11