Closed tearandfix closed 2 years ago
Thanks for the report. I suspect a recent change to the flags code broke this. Apologies for that.
But given that you have a compile_commands.json, I would strongly recommend you switch to using clangd
(rather than the now-legacy libclang completer) and remove your .ycm_extra_conf.py entirely. This will give you a much better experience, with many more features, faster and a complete index.
I can't build your repro case:
ben@BeniMac2020 cmake-example % cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-- The Fortran compiler identification is unknown
CMake Error at CMakeLists.txt:5 (project):
No CMAKE_Fortran_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "FC" or the CMake cache entry CMAKE_Fortran_COMPILER to the full
path to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "/Users/ben/Development/YouCompleteMe/cmake-example/build/CMakeFiles/CMakeOutput.log".
See also "/Users/ben/Development/YouCompleteMe/cmake-example/build/CMakeFiles/CMakeError.log".
I see there is no .ycm_extra_conf.py
in there, but I still recommend switching to clangd ./install.py --clangd-completer
.
OK I installed a fortran compiler and it works.
Hmm interesting, it doesn't reproduce on macOS (which is OK because we have different flags manipulations for macOS):
-- C-family completer debug information:
-- Compilation database path: /Users/ben/Development/YouCompleteMe/cmake-example
-- Flags: ['/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++', '-x', 'c++', '--driver-mode=g++', '-I/Users/ben/Development/YouCompleteMe/cmake
-example/src', '-O3', '-DNDEBUG', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk', '-resource-dir=/Users/ben/.vim/bundle
/YouCompleteMe/third_party/ycmd/third_party/clang/lib/clang/14.0.0', '-isystem', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/i
nclude/c++/v1', '-isystem', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/local/include', '-isystem', '/usr/local/include', '-is
ystem', '/Users/ben/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/clang/lib/clang/14.0.0/include', '-isystem', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefaul
t.xctoolchain/usr/include', '-isystem', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include', '-iframework', '/Applications/Xc
ode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks', '-iframework', '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX
.platform/Developer/SDKs/MacOSX12.3.sdk/Library/Frameworks', '-fspell-checking']
-- Translation unit: /Users/ben/Development/YouCompleteMe/cmake-example/src/example.h
Can you share the generated compile_commands.json ?
I've switched to --clangd-completer
and it solved the issue. Thanks.
I can't build your repro case
Probably some environment issue. But I was able to reproduce it on any cmake project with a header file. Cmake project needs to generate 'compile_commands.json`
Can you share the generated compile_commands.json ?
https://gist.github.com/tearandfix/168acd485a2af235a137bb23afd9268e#file-compile_commands-json
This was broken by the upgrade to clang 14.0. The libclang compilation database now returns the extra --
flag. We'll need to filter it out.
Issue Prelude
After system update I'm having
ClangParseError: An AST deserialization error occurred while parsing the translation unit.
for all .h/.hpp files. I'm usingcompile_commands.json
for compilation flags. It seems like the problem is with flags for headers. There's addition '--' flag in the flags for the header and it causes this error. It seems like when the flags are deduced from .cpp file an additional '--' is included for some reason. If I manually place a record incompile_commands.json
for the header just by copying it from the .cpp file there is no error.Can you please point me to the place where compilation flags are formed for the header? I mean where they are copied from the corresponding .cpp file?
I tried it on a simple cmake example: https://github.com/bast/cmake-example I've also tried downgrading YouCompleteMe, ycmd, vim, python without success.
Please complete these steps and check these boxes (by putting an
x
inside the brackets) before filing your issue:vim --version
.:YcmDebugInfo
.:YcmToggleLogs
command.vim -Nu /path/to/YCM/vimrc_ycm_minimal
, including what I expected to happen and what actually happened.install.py
(orcmake
/make
/ninja
) including its invocationThank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.
Issue Details
https://github.com/bast/cmake-example.git
cd cmake-example
mkdir build
cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
cd ..
cp build/compile_commands.json .
vim -Nu ~/.vim/bundle/YouCompleteMe/vimrc_ycm_minimal src/example.h
I expect ycm to work with header file the same way as with the source file.
YCM reports error:
ClangParseError: An AST deserialization error occurred while parsing the translation unit.
:YcmDebugInfo
shows additional '--' in the flags. Which I believe caused this error.Diagnostic data
Output of
vim --version
Output of
YcmDebugInfo
Output of
YcmDiags
Output of
git rev-parse HEAD
in YouCompleteMe installation directoryContents of YCM, ycmd and completion engine logfiles
OS version, distribution, etc.
Arch Linux up to date
Output of build/install commands