Zig Version
0.15.2
Steps to Reproduce and Observed Behavior
Install Msys2 and install zig by
pacman -S mingw-w64-clang-x86_64-zig \
mingw-w64-clang-x86_64-cmake \
mingw-w64-clang-x86_64-ninja
Install VSCode and clangd extension in the marketplace.
Clone mrexodia/zig-cross to a workspace folder, in my case <workspace>/3rdparty.
Modify the *.cmd files in zig-cross/cmake by changing zig to <full-path-to-zig>, in my case C:\msys64\clang64\bin\zig.exe.
Set VSCode settings for a workspace with
{
"clangd.path": "C:/msys64/clang64/bin/clangd.exe",
"clangd.arguments": [
"--query-driver=D:/Repos/zig_test/3rdparty/zig-cross/cmake/zig-cc.cmd,D:/Repos/zig_test/3rdparty/zig-cross/cmake/zig-c++.cmd",
"--log=verbose",
"--pretty",
"--compile-commands-dir=${workspaceFolder}",
"--header-insertion=never",
"--all-scopes-completion",
"--clang-tidy",
"--pch-storage=memory",
"-j=4"
]
}
Create a C++ source file main.cc
#include <iostream>
int main() {
std::cout << "Hello, world" << std::endl;
return 0;
}
Create CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
project(text LANGUAGES CXX)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_executable(test main.cc)
Run several commands in Msys2/UCRT64 shell
mkdir build && cd build && cmake -D CMAKE_TOOLCHAIN_FILE=3rdparty/zig-cross/x86_64-windows-gnu.cmake ..
cp -pv compile_commands.json ..
Now restart the clangd language server.
The language server doesnot work properly because of missing definitions for libc++.
After some digging, I found that there should be a __config_site.h in libc++, but it seems that zig will use -D when compiling. Clangd failed to detect these definitions, so it cannot work unless we use the verbose mode to compile and add these definitions manually in CMakeLists.txt to generate a database file which contains these definitions.
Expected Behavior
When using clang in Msys2/UCRT64, clangd works fine.

Zig Version
0.15.2
Steps to Reproduce and Observed Behavior
Install Msys2 and install zig by
pacman -S mingw-w64-clang-x86_64-zig \ mingw-w64-clang-x86_64-cmake \ mingw-w64-clang-x86_64-ninjaInstall VSCode and clangd extension in the marketplace.
Clone mrexodia/zig-cross to a workspace folder, in my case
<workspace>/3rdparty.Modify the
*.cmdfiles inzig-cross/cmakeby changingzigto<full-path-to-zig>, in my caseC:\msys64\clang64\bin\zig.exe.Set VSCode settings for a workspace with
{ "clangd.path": "C:/msys64/clang64/bin/clangd.exe", "clangd.arguments": [ "--query-driver=D:/Repos/zig_test/3rdparty/zig-cross/cmake/zig-cc.cmd,D:/Repos/zig_test/3rdparty/zig-cross/cmake/zig-c++.cmd", "--log=verbose", "--pretty", "--compile-commands-dir=${workspaceFolder}", "--header-insertion=never", "--all-scopes-completion", "--clang-tidy", "--pch-storage=memory", "-j=4" ] }Create a C++ source file
main.ccCreate
CMakeLists.txtRun several commands in Msys2/UCRT64 shell
Now restart the clangd language server.
The language server doesnot work properly because of missing definitions for libc++.
After some digging, I found that there should be a
__config_site.hin libc++, but it seems that zig will use-Dwhen compiling. Clangd failed to detect these definitions, so it cannot work unless we use the verbose mode to compile and add these definitions manually inCMakeLists.txtto generate a database file which contains these definitions.Expected Behavior
When using clang in Msys2/UCRT64, clangd works fine.