Open palapapa opened 1 year ago
The usual diagnostic strategy to try in a situation like this is to take the command clangd tells you it's running from the log, and try running it on the command line, with the slight modification of removing the -resource-dir
argument which it adds.
So that gives us:
"C:\\mingw64\\bin\\clang" -Weverything -Wno-used-but-marked-unused -Wno-declaration-after-statement -Wno-vla -Wno-missing-prototypes -Wno-c++98-compat -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32 -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0 -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include -nostdinc -target x86_64-pc-windows-gnu -std=c++20 -- "d:\\Download\\main.cpp"
Does that give any errors when run on the command line?
That gives:
In file included from d:\\Download\\main.cpp:1:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/iostream:34:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
#define _GLIBCXX_IOSTREAM 1
^
In file included from d:\\Download\\main.cpp:2:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/vector:56:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
#define _GLIBCXX_VECTOR 1
^
In file included from d:\\Download\\main.cpp:3:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/stdlib.h:34:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
#define _GLIBCXX_STDLIB_H 1
^
3 warnings generated.
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.text+0xc): undefined reference to `std::ios_base::Init::Init()'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.text+0x3c): undefined reference to `std::ios_base::Init::~Init()'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.xdata$_ZNSt6vectorIiSaIiEED2Ev+0x8): undefined reference to `__gxx_personality_seh0'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.text$__clang_call_terminate[__clang_call_terminate]+0x5): undefined reference to `__cxa_begin_catch'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.text$__clang_call_terminate[__clang_call_terminate]+0xa): undefined reference to `std::terminate()'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.xdata$_ZNSt12_Vector_baseIiSaIiEED2Ev+0x8): undefined reference to `__gxx_personality_seh0'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-b4c5ae.o:main.cpp:(.text$_ZNSt15__new_allocatorIiE10deallocateEPiy[_ZNSt15__new_allocatorIiE10deallocateEPiy]+0x19): undefined reference to `operator delete(void*)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
With -v
:
(built by Brecht Sanders) clang version 16.0.0
Target: x86_64-pc-windows-gnu
Thread model: posix
InstalledDir: C:/mingw64/bin
"C:/mingw64/bin/clang.exe" -cc1 -triple x86_64-pc-windows-gnu -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -mms-bitfields -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=D:/Download -nostdsysteminc -nobuiltininc -resource-dir C:/mingw64/lib/clang/16 -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32 -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0 -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include -Weverything -Wno-used-but-marked-unused -Wno-declaration-after-statement -Wno-vla -Wno-missing-prototypes -Wno-c++98-compat -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=D:/Download -ferror-limit 19 -fmessage-length=252 -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -exception-model=seh -fcolor-diagnostics -faddrsig -o C:/Users/User/AppData/Local/Temp/main-1dc091.o -x c++ "d:\\\\Download\\\\main.cpp"
clang -cc1 version 16.0.0 based upon LLVM 16.0.0 default target x86_64-w64-mingw32
#include "..." search starts here:
#include <...> search starts here:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include
End of search list.
In file included from d:\\Download\\main.cpp:1:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/iostream:34:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
#define _GLIBCXX_IOSTREAM 1
^
In file included from d:\\Download\\main.cpp:2:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/vector:56:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
#define _GLIBCXX_VECTOR 1
^
In file included from d:\\Download\\main.cpp:3:
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/stdlib.h:34:9: warning: macro name is a reserved identifier [-Wreserved-macro-identifier]
#define _GLIBCXX_STDLIB_H 1
^
3 warnings generated.
"C:/mingw64/bin/ld" -m i386pep -Bdynamic -o a.exe C:/mingw64/x86_64-w64-mingw32/lib/crt2.o C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/crtbegin.o -LC:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0 -LC:/mingw64/x86_64-w64-mingw32/lib -LC:/mingw64/x86_64-w64-mingw32/mingw/lib -LC:/mingw64/lib C:/Users/User/AppData/Local/Temp/main-1dc091.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 C:/mingw64/lib/gcc/x86_64-w64-mingw32/12.2.0/crtend.o
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.text+0xc): undefined reference to `std::ios_base::Init::Init()'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.text+0x3c): undefined reference to `std::ios_base::Init::~Init()'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.xdata$_ZNSt6vectorIiSaIiEED2Ev+0x8): undefined reference to `__gxx_personality_seh0'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.text$__clang_call_terminate[__clang_call_terminate]+0x5): undefined reference to `__cxa_begin_catch'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.text$__clang_call_terminate[__clang_call_terminate]+0xa): undefined reference to `std::terminate()'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.xdata$_ZNSt12_Vector_baseIiSaIiEED2Ev+0x8): undefined reference to `__gxx_personality_seh0'
C:/mingw64/bin/ld: C:/Users/User/AppData/Local/Temp/main-1dc091.o:main.cpp:(.text$_ZNSt15__new_allocatorIiE10deallocateEPiy[_ZNSt15__new_allocatorIiE10deallocateEPiy]+0x19): undefined reference to `operator delete(void*)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Interesting, so the command line version is not giving the same errors you're seeing in the editor.
I wonder if the difference in versions (clangd 15 vs. clang 16) is relevant here. Are you by chance able to test the command-line command with clang 15, or alternatively try using clangd 16 to match your compiler version?
Somehow by completely removing clang from my PATH
, it worked correctly again. No errors were reported and the includes were correctly found. Here's the log:
I[21:41:08.818] clangd version 15.0.3 (https://github.com/llvm/llvm-project 4a2c05b05ed07f1f620e94f6524a8b4b2760a0b1)
I[21:41:08.819] Features: windows+grpc
I[21:41:08.819] PID: 17208
I[21:41:08.819] Working directory: C:\Users\User\AppData\Local\Programs\Microsoft VS Code
I[21:41:08.819] argv[0]: c:\Users\User\AppData\Roaming\Code\User\globalStorage\llvm-vs-code-extensions.vscode-clangd\install\15.0.3\clangd_15.0.3\bin\clangd.exe
I[21:41:08.819] argv[1]: --log=verbose
V[21:41:08.824] User config file is C:\Users\User\AppData\Local\clangd\config.yaml
I[21:41:08.824] Starting LSP over stdin/stdout
V[21:41:08.917] <<< {"id":0,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"markdown":{"parser":"marked","version":"1.1.0"},"positionEncodings":["utf-16"],"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"staleRequestSupport":{"cancel":true,"retryOnContentModified":["textDocument/semanticTokens/full","textDocument/semanticTokens/range","textDocument/semanticTokens/full/delta"]}},"notebookDocument":{"synchronization":{"dynamicRegistration":true,"executionSummarySupport":true}},"textDocument":{"callHierarchy":{"dynamicRegistration":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"dynamicRegistration":true,"honorsChangeAnnotations":false,"isPreferredSupport":true,"resolveSupport":{"properties":["edit"]}},"codeLens":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"completion":{"completionItem":{"commitCharactersSupport":true,"deprecatedSupport":true,"documentationFormat":["markdown","plaintext"],"insertReplaceSupport":true,"insertTextModeSupport":{"valueSet":[1,2]},"labelDetailsSupport":true,"preselectSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"completionList":{"itemDefaults":["commitCharacters","editRange","insertTextFormat","insertTextMode"]},"contextSupport":true,"dynamicRegistration":true,"editsNearCursor":true,"insertTextMode":2},"declaration":{"dynamicRegistration":true,"linkSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"diagnostic":{"dynamicRegistration":true,"relatedDocumentSupport":false},"documentHighlight":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"documentSymbol":{"dynamicRegistration":true,"hierarchicalDocumentSymbolSupport":true,"labelSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"foldingRange":{"dynamicRegistration":true,"foldingRange":{"collapsedText":false},"foldingRangeKind":{"valueSet":["comment","imports","region"]},"lineFoldingOnly":true,"rangeLimit":5000},"formatting":{"dynamicRegistration":true},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"inlayHint":{"dynamicRegistration":true,"resolveSupport":{"properties":["tooltip","textEdits","label.tooltip","label.location","label.command"]}},"inlineValue":{"dynamicRegistration":true},"linkedEditingRange":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"publishDiagnostics":{"codeDescriptionSupport":true,"dataSupport":true,"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":false},"rangeFormatting":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"honorsChangeAnnotations":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1},"selectionRange":{"dynamicRegistration":true},"semanticTokens":{"augmentsSyntaxTokens":true,"dynamicRegistration":true,"formats":["relative"],"multilineTokenSupport":false,"overlappingTokenSupport":false,"requests":{"full":{"delta":true},"range":true},"serverCancelSupport":true,"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator","decorator"]},"signatureHelp":{"contextSupport":true,"dynamicRegistration":true,"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true,"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"typeHierarchy":{"dynamicRegistration":true}},"window":{"showDocument":{"support":true},"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"workDoneProgress":true},"workspace":{"applyEdit":true,"codeLens":{"refreshSupport":true},"configuration":true,"diagnostics":{"refreshSupport":true},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":true},"executeCommand":{"dynamicRegistration":true},"fileOperations":{"didCreate":true,"didDelete":true,"didRename":true,"dynamicRegistration":true,"willCreate":true,"willDelete":true,"willRename":true},"inlayHint":{"refreshSupport":true},"inlineValue":{"refreshSupport":true},"semanticTokens":{"refreshSupport":true},"symbol":{"dynamicRegistration":true,"resolveSupport":{"properties":["location.range"]},"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"workspaceEdit":{"changeAnnotationSupport":{"groupsOnLabel":true},"documentChanges":true,"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"Visual Studio Code","version":"1.77.3"},"initializationOptions":{"clangdFileStatus":true,"fallbackFlags":["-Weverything","-Wno-used-but-marked-unused","-Wno-declaration-after-statement","-Wno-vla","-Wno-missing-prototypes","-Wno-c++98-compat","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed","-IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include","-nostdinc","-target","x86_64-pc-windows-gnu"]},"locale":"en","processId":14244,"rootPath":null,"rootUri":null,"trace":"off","workspaceFolders":null}}
I[21:41:08.917] <-- initialize(0)
I[21:41:08.958] --> reply:initialize(0) 40 ms
V[21:41:08.958] >>> {"id":0,"jsonrpc":"2.0","result":{"capabilities":{"astProvider":true,"callHierarchyProvider":true,"clangdInlayHintsProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor","info"]},"compilationDatabase":{"automaticReload":true},"completionProvider":{"resolveProvider":false,"triggerCharacters":[".","<",">",":","\"","/","*"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"hoverProvider":true,"implementationProvider":true,"inlayHintProvider":true,"memoryUsageProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":["declaration","deprecated","deduced","readonly","static","abstract","virtual","dependentName","defaultLibrary","usedAsMutableReference","functionScope","classScope","fileScope","globalScope"],"tokenTypes":["variable","variable","parameter","function","method","function","property","variable","class","interface","enum","enumMember","type","type","unknown","namespace","typeParameter","concept","type","macro","comment"]},"range":false},"signatureHelpProvider":{"triggerCharacters":["(",")","{","}","<",">",","]},"standardTypeHierarchyProvider":true,"textDocumentSync":{"change":2,"openClose":true,"save":true},"typeDefinitionProvider":true,"typeHierarchyProvider":true,"workspaceSymbolProvider":true},"serverInfo":{"name":"clangd","version":"clangd version 15.0.3 (https://github.com/llvm/llvm-project 4a2c05b05ed07f1f620e94f6524a8b4b2760a0b1) windows+grpc x86_64-pc-windows-msvc"}}}
V[21:41:10.316] <<< {"jsonrpc":"2.0","method":"initialized","params":{}}
I[21:41:10.316] <-- initialized
V[21:41:10.477] <<< {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"#include <iostream>\r\n#include <vector>\r\n#include <stdlib.h>\r\n\r\nint main()\r\n{\r\n std::vector<int> v;\r\n}\r\n","uri":"file:///d%3A/Download/main.cpp","version":1}}}
I[21:41:10.477] <-- textDocument/didOpen
I[21:41:10.479] Failed to find compilation database for d:\Download\main.cpp
I[21:41:10.479] ASTWorker building file d:\Download\main.cpp version 1 with command clangd fallback
[d:\Download]
"c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\bin\\clang" -Weverything -Wno-used-but-marked-unused -Wno-declaration-after-statement -Wno-vla -Wno-missing-prototypes -Wno-c++98-compat -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32 -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0 -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed -IC:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include -nostdinc -target x86_64-pc-windows-gnu "-resource-dir=c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\lib\\clang\\15.0.3" -- "d:\\Download\\main.cpp"
V[21:41:10.512] <<< {"id":1,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}
I[21:41:10.512] <-- textDocument/documentSymbol(1)
V[21:41:10.525] Driver produced command: cc1 -cc1 -triple x86_64-pc-windows-gnu -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -mms-bitfields -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb "-fcoverage-compilation-dir=d:\\Download" -nostdsysteminc -nobuiltininc -resource-dir "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\lib\\clang\\15.0.3" -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/x86_64-w64-mingw32 -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0 -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0/backward -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/include-fixed -I C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/include -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\x86_64-w64-mingw32\\include\\c++" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\x86_64-w64-mingw32\\include\\c++\\x86_64-w64-mingw32" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\x86_64-w64-mingw32\\include\\c++\\backward" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\x86_64-w64-mingw32\\include\\c++\\" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\x86_64-w64-mingw32\\include\\c++\\\\x86_64-w64-mingw32" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\x86_64-w64-mingw32\\include\\c++\\\\backward" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\include\\c++\\" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\include\\c++\\\\x86_64-w64-mingw32" -internal-isystem "c:\\Users\\User\\AppData\\Roaming\\Code\\User\\globalStorage\\llvm-vs-code-extensions.vscode-clangd\\install\\15.0.3\\clangd_15.0.3\\include\\c++\\\\backward" -internal-isystem "include\\c++" -internal-isystem "include\\c++\\x86_64-w64-mingw32" -internal-isystem "include\\c++\\backward" -internal-isystem "include\\g++-v0.0.0" -internal-isystem "include\\g++-v0.0.0\\x86_64-w64-mingw32" -internal-isystem "include\\g++-v0.0.0\\backward" -internal-isystem "include\\g++-v0.0" -internal-isystem "include\\g++-v0.0\\x86_64-w64-mingw32" -internal-isystem "include\\g++-v0.0\\backward" -internal-isystem "include\\g++-v0" -internal-isystem "include\\g++-v0\\x86_64-w64-mingw32" -internal-isystem "include\\g++-v0\\backward" -Weverything -Wno-used-but-marked-unused -Wno-declaration-after-statement -Wno-vla -Wno-missing-prototypes -Wno-c++98-compat -fdeprecated-macro "-fdebug-compilation-dir=d:\\Download" -ferror-limit 19 -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -exception-model=seh -no-round-trip-args -faddrsig -x c++ "d:\\Download\\main.cpp"
I[21:41:10.525] --> textDocument/clangd.fileStatus
V[21:41:10.525] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Update","uri":"file:///d:/Download/main.cpp"}}
V[21:41:10.525] Building first preamble for d:\Download\main.cpp version 1
V[21:41:10.550] <<< {"id":2,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}
I[21:41:10.550] <-- textDocument/documentLink(2)
V[21:41:10.851] Dropped diagnostic: C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0\iostream: macro name is a reserved identifier
V[21:41:10.867] Dropped diagnostic: C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0\vector: macro name is a reserved identifier
V[21:41:11.044] indexed preamble AST for d:\Download\main.cpp version 1:
symbol slab: 5132 symbols, 1588064 bytes
ref slab: 0 symbols, 0 refs, 136 bytes
relations slab: 287 relations, 5396 bytes
V[21:41:11.093] Build dynamic index for header symbols with estimated memory usage of 3642040 bytes
V[21:41:11.093] Dropped diagnostic: C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../include/c++/12.2.0\stdlib.h: macro name is a reserved identifier
V[21:41:11.100] Built preamble of size 3045280 for file d:\Download\main.cpp version 1 in 0.57 seconds
I[21:41:11.101] --> workspace/semanticTokens/refresh(0)
I[21:41:11.101] --> textDocument/clangd.fileStatus
V[21:41:11.101] >>> {"id":0,"jsonrpc":"2.0","method":"workspace/semanticTokens/refresh","params":null}
V[21:41:11.101] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Build AST","uri":"file:///d:/Download/main.cpp"}}
V[21:41:11.188] indexed file AST for d:\Download\main.cpp version 1:
symbol slab: 1 symbols, 4456 bytes
ref slab: 3 symbols, 3 refs, 4304 bytes
relations slab: 0 relations, 24 bytes
V[21:41:11.188] Build dynamic index for main-file symbols with estimated memory usage of 11648 bytes
I[21:41:11.188] --> textDocument/publishDiagnostics
V[21:41:11.188] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///d:/Download/main.cpp","version":1}}
V[21:41:11.188] ASTWorker running DocumentSymbols on version 1 of d:\Download\main.cpp
I[21:41:11.188] --> reply:textDocument/documentSymbol(1) 676 ms
V[21:41:11.188] >>> {"id":1,"jsonrpc":"2.0","result":[{"detail":"int ()","kind":12,"name":"main","range":{"end":{"character":1,"line":7},"start":{"character":0,"line":4}},"selectionRange":{"end":{"character":8,"line":4},"start":{"character":4,"line":4}}}]}
V[21:41:11.188] ASTWorker running DocumentLinks on version 1 of d:\Download\main.cpp
I[21:41:11.188] --> reply:textDocument/documentLink(2) 638 ms
V[21:41:11.188] >>> {"id":2,"jsonrpc":"2.0","result":[{"range":{"end":{"character":19,"line":0},"start":{"character":9,"line":0}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/iostream"},{"range":{"end":{"character":17,"line":1},"start":{"character":9,"line":1}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/vector"},{"range":{"end":{"character":19,"line":2},"start":{"character":9,"line":2}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/stdlib.h"}]}
I[21:41:11.188] --> textDocument/clangd.fileStatus
V[21:41:11.188] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}
V[21:41:11.273] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":2}}
I[21:41:11.273] <-- $/cancelRequest
V[21:41:11.371] <<< {"id":3,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}
I[21:41:11.371] <-- textDocument/documentLink(3)
V[21:41:11.371] ASTWorker running DocumentLinks on version 1 of d:\Download\main.cpp
I[21:41:11.371] --> reply:textDocument/documentLink(3) 0 ms
V[21:41:11.371] >>> {"id":3,"jsonrpc":"2.0","result":[{"range":{"end":{"character":19,"line":0},"start":{"character":9,"line":0}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/iostream"},{"range":{"end":{"character":17,"line":1},"start":{"character":9,"line":1}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/vector"},{"range":{"end":{"character":19,"line":2},"start":{"character":9,"line":2}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/stdlib.h"}]}
I[21:41:11.371] --> textDocument/clangd.fileStatus
V[21:41:11.371] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}
V[21:41:11.392] <<< {"jsonrpc":"2.0","method":"$/cancelRequest","params":{"id":1}}
I[21:41:11.392] <-- $/cancelRequest
V[21:41:11.437] <<< {"id":4,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}
I[21:41:11.437] <-- textDocument/documentSymbol(4)
V[21:41:11.437] ASTWorker running DocumentSymbols on version 1 of d:\Download\main.cpp
I[21:41:11.437] --> reply:textDocument/documentSymbol(4) 0 ms
V[21:41:11.437] >>> {"id":4,"jsonrpc":"2.0","result":[{"detail":"int ()","kind":12,"name":"main","range":{"end":{"character":1,"line":7},"start":{"character":0,"line":4}},"selectionRange":{"end":{"character":8,"line":4},"start":{"character":4,"line":4}}}]}
I[21:41:11.437] --> textDocument/clangd.fileStatus
V[21:41:11.437] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}
V[21:41:11.448] <<< {"id":5,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}
I[21:41:11.448] <-- textDocument/semanticTokens/full(5)
V[21:41:11.448] ASTWorker running SemanticHighlights on version 1 of d:\Download\main.cpp
I[21:41:11.448] --> reply:textDocument/semanticTokens/full(5) 0 ms
V[21:41:11.448] >>> {"id":5,"jsonrpc":"2.0","result":{"data":[4,4,4,3,8193,2,4,3,15,8448,0,5,6,8,8448,0,12,1,1,1025],"resultId":"1"}}
I[21:41:11.448] --> textDocument/clangd.fileStatus
V[21:41:11.448] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}
V[21:41:11.463] <<< {"id":0,"jsonrpc":"2.0","result":null}
I[21:41:11.463] <-- reply(0)
V[21:41:11.479] <<< {"id":6,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}
I[21:41:11.479] <-- textDocument/documentLink(6)
V[21:41:11.479] ASTWorker running DocumentLinks on version 1 of d:\Download\main.cpp
I[21:41:11.479] --> reply:textDocument/documentLink(6) 0 ms
V[21:41:11.479] >>> {"id":6,"jsonrpc":"2.0","result":[{"range":{"end":{"character":19,"line":0},"start":{"character":9,"line":0}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/iostream"},{"range":{"end":{"character":17,"line":1},"start":{"character":9,"line":1}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/vector"},{"range":{"end":{"character":19,"line":2},"start":{"character":9,"line":2}},"target":"file:///C:/mingw64/include/c%2B%2B/12.2.0/stdlib.h"}]}
I[21:41:11.479] --> textDocument/clangd.fileStatus
V[21:41:11.479] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}
V[21:41:13.842] <<< {"id":7,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"file:///d%3A/Download/main.cpp"}}}
I[21:41:13.842] <-- textDocument/semanticTokens/full(7)
V[21:41:13.842] ASTWorker running SemanticHighlights on version 1 of d:\Download\main.cpp
I[21:41:13.842] --> reply:textDocument/semanticTokens/full(7) 0 ms
V[21:41:13.842] >>> {"id":7,"jsonrpc":"2.0","result":{"data":[4,4,4,3,8193,2,4,3,15,8448,0,5,6,8,8448,0,12,1,1,1025],"resultId":"2"}}
I[21:41:13.842] --> textDocument/clangd.fileStatus
V[21:41:13.842] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///d:/Download/main.cpp"}}
I tried to do that because I remembered I used to not have clang installed and it also worked. Does this mean that clangd doesn't need clang to function?
Does this mean that clangd doesn't need clang to function?
Correct, clangd does not invoke a clang executable.
It does use clang's libraries and some built-in headers, but those are usually included in the clangd package (or in some package manager setups, clang and clangd may share the libraries as a common dependency).
As for why the presence of clang impacts clangd in this way, I'm not sure, sorry. I'm not a Windows user so my ability to provide help with Windows issues is somewhat limited. I think clangd would benefit from someone who does use Windows who would be willing to take the time to dive more deeply into these sorts of issues.
I thought deleting clang worked but it actually didn't. This issue appeared again without me changing any configs.
It seems that by setting the --target
to x86_64-w64-windows-gnu
, clangd will automatically detect the MinGW headers and work correctly.
With this piece of code:
clangd gave these errors: Notice how the
stdlib.h
in the code didn't generate an error but it did foriostream
. It also gave a few strange errors forstd::vector
.My flags:
Logs
System information Clangd version (from the log, or
clangd --version
): 15.0.3 clangd extension version: 0.1.24 Operating system: Windows 10