Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't build compiler instance #1399

Closed
kaydxh opened this issue Nov 28, 2022 · 7 comments
Closed

Couldn't build compiler instance #1399

kaydxh opened this issue Nov 28, 2022 · 7 comments

Comments

@kaydxh
Copy link

kaydxh commented Nov 28, 2022

I can't jump to GoToDefinitionElseDeclaration in cpp with YouCompleteMe [https://github.com/ycm-core/YouCompleteMe/issues/4085] and my os system is centos 8, It looks like clangd is choking on compiler flags and unable to read them and instantiate the front end.
Logs
image

System information

Output of clangd --version:
clangd version 15.0.1 (https://github.com/ycm-core/llvm 708056a3d8259ce1d9fc0f15676d13b53cc23835) Features: linux Platform: x86_64-unknown-linux-gnu
Editor/LSP plugin:
vim version 9.0.950
Operating system:
centos8

@sam-mccall
Copy link
Member

Please include full logs (not a screenshot) from clangd -log=verbose -check=some/affected/file.cpp.

@kaydxh
Copy link
Author

kaydxh commented Nov 29, 2022

Please include full logs (not a screenshot) from clangd -log=verbose -check=some/affected/file.cpp.
Full logs from : clangd -log=verbose -check= /data/home/sea/src/retrieve/cache_loader.cpp

I[00:22:08.194] clangd version 15.0.1 (https://github.com/ycm-core/llvm 708056a3d8259ce1d9fc0f15676d13b53cc23835)
I[00:22:08.194] Features: linux
I[00:22:08.194] PID: 28478
I[00:22:08.194] Working directory: /data/home/sea
I[00:22:08.194] argv[0]: /root/.vim/pack/minpac/start/YouCompleteMe/third_party/ycmd/third_party/clangd/output/bin/clangd
I[00:22:08.194] argv[1]: -log=verbose
I[00:22:08.194] argv[2]: -check=src/retrieve/cache_loader.cpp
V[00:22:08.194] User config file is /root/.config/clangd/config.yaml
I[00:22:08.194] Entering check mode (no LSP server)
I[00:22:08.194] Testing on source file /data/home/sea/src/retrieve/cache_loader.cpp
I[00:22:08.194] Loading compilation database...
I[00:22:08.197] Loaded compilation database from /data/home/sea/compile_commands.json
V[00:22:08.197] Broadcasting compilation database from /data/home/sea
I[00:22:08.197] Compile command from CDB is: /usr/bin/c++ --driver-mode=g++ -DENABLE_POLARIS -DENABLE_RAINBOW -DENABLE_ULS -DENABLE_ZHIYAN -I/data/home/sea/third_path/aio_common/include -I/data/home/sea/third_path/apollo/include -I/data/home/sea/third_path/boost/include -I/data/home/sea/third_path/brpc/include -I/data/home/sea/third_path/cuda/include -I/data/home/sea/third_path/curl/include -I/data/home/sea/third_path/gflags/include -I/data/home/sea/third_path/gif/include -I/data/home/sea/third_path/glog/include -I/data/home/sea/third_path/graphicsMagick/include -I/data/home/sea/third_path/gtest/include -I/data/home/sea/third_path/hiredis/include -I/data/home/sea/third_path/leveldb/include -I/data/home/sea/third_path/libevent/include -I/data/home/sea/third_path/libqos_client/include -I/data/home/sea/third_path/mklml/include -I/data/home/sea/third_path/mysqlclient/include -I/data/home/sea/third_path/opencv/include -I/data/home/sea/third_path/openssl/include -I/data/home/sea/third_path/polaris/include -I/data/home/sea/third_path/protobuf/include -I/data/home/sea/third_path/rainbow/include -I/data/home/sea/third_path/rapid1vn/include -I/data/home/sea/third_path/rapidjson/include -I/data/home/sea/third_path/snappy/include -I/data/home/sea/third_path/xflog/include -I/data/home/sea/third_path/yt_face_search/include -I/data/home/sea/third_path/yun_uls_client/include -I/data/home/sea/third_path/zhiyan_monitor/include -I/data/home/sea/src/proto -I/data/home/sea/src/proto/public -I/data/home/sea/src/proto/services -I/data/home/sea/src -mfpmath=both -g3 -ggdb -fPIC -rdynamic -msse -msse2 -msse3 -msse4.1 -mavx -mavx2 -Wall -Werror -Wextra -Wno-unused-variable -Wno-sign-compare -Wno-unused-function -Wno-unused-local-typedefs -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unknown-pragmas -DNGX_DEBUG -D__const__= -DBRPC_WITH_GLOG=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -DMAGICKCORE_HDRI_ENABLE=1 -DRAPIDJSON_HAS_STDSTRING=1 -fpermissive -Wl,--eh-frame-hdr -faligned-new -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -g -w -o CMakeFiles/retrieve_server.dir/cache_loader.cpp.o -c -resource-dir=/root/.vim/pack/minpac/start/YouCompleteMe/third_party/ycmd/third_party/clangd/output/lib/clang/15.0.1 -- /data/home/sea/src/retrieve/cache_loader.cpp
I[00:22:08.197] Giving up on broadcasting CDB, as we're shutting down
I[00:22:08.198] Parsing command...
I[00:22:08.199] internal (cc1) args are: -cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name cache_loader.cpp -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mfpmath both -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -target-feature +sse -target-feature +sse2 -target-feature +sse3 -target-feature +sse4.1 -target-feature +avx -target-feature +avx2 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -fcoverage-compilation-dir=/data/home/sea/build/src/retrieve -resource-dir /root/.vim/pack/minpac/start/YouCompleteMe/third_party/ycmd/third_party/clangd/output/lib/clang/15.0.1 -D ENABLE_POLARIS -D ENABLE_RAINBOW -D ENABLE_ULS -D ENABLE_ZHIYAN -I /data/home/sea/third_path/aio_common/include -I /data/home/sea/third_path/apollo/include -I /data/home/sea/third_path/boost/include -I /data/home/sea/third_path/brpc/include -I /data/home/sea/third_path/cuda/include -I /data/home/sea/third_path/curl/include -I /data/home/sea/third_path/gflags/include -I /data/home/sea/third_path/gif/include -I /data/home/sea/third_path/glog/include -I /data/home/sea/third_path/graphicsMagick/include -I /data/home/sea/third_path/gtest/include -I /data/home/sea/third_path/hiredis/include -I /data/home/sea/third_path/leveldb/include -I /data/home/sea/third_path/libevent/include -I /data/home/sea/third_path/libqos_client/include -I /data/home/sea/third_path/mklml/include -I /data/home/sea/third_path/mysqlclient/include -I /data/home/sea/third_path/opencv/include -I /data/home/sea/third_path/openssl/include -I /data/home/sea/third_path/polaris/include -I /data/home/sea/third_path/protobuf/include -I /data/home/sea/third_path/rainbow/include -I /data/home/sea/third_path/rapid1vn/include -I /data/home/sea/third_path/rapidjson/include -I /data/home/sea/third_path/snappy/include -I /data/home/sea/third_path/xflog/include -I /data/home/sea/third_path/yt_face_search/include -I /data/home/sea/third_path/yun_uls_client/include -I /data/home/sea/third_path/zhiyan_monitor/include -I /data/home/sea/src/proto -I /data/home/sea/src/proto/public -I /data/home/sea/src/proto/services -I /data/home/sea/src -D NGX_DEBUG -D __const__= -D BRPC_WITH_GLOG=1 -D MAGICKCORE_QUANTUM_DEPTH=16 -D MAGICKCORE_HDRI_ENABLE=1 -D RAPIDJSON_HAS_STDSTRING=1 -D _GLIBCXX_USE_CXX11_ABI=0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/backward -internal-isystem /root/.vim/pack/minpac/start/YouCompleteMe/third_party/ycmd/third_party/clangd/output/lib/clang/15.0.1/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall -Werror -Wextra -Wno-unused-variable -Wno-sign-compare -Wno-unused-function -Wno-unused-local-typedefs -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unknown-pragmas -w -std=c++11 -fdeprecated-macro -fdebug-compilation-dir=/data/home/sea/build/src/retrieve -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -faligned-allocation -no-round-trip-args -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ /data/home/sea/src/retrieve/cache_loader.cpp
I[00:22:08.199] Building preamble...
E[00:22:08.199] Could not build a preamble for file /data/home/sea/src/retrieve/cache_loader.cpp version null: CreateTargetInfo() return null
E[00:22:08.199] Failed to build preamble

@Piratezoe
Copy link

Please include full logs (not a screenshot) from clangd -log=verbose -check=some/affected/file.cpp.

Execuse me,
Where should I add "-log=verbose" if i was using coc.clangd as client?

@Piratezoe
Copy link

Please include full logs (not a screenshot) from clangd -log=verbose -check=some/affected/file.cpp.

Execuse me, Where should I add "-log=verbose" if i was using coc.clangd as client?

ITS OK, I found that, Over the below argument.

clangd.arguments arguments for clangd server []

@kaydxh
Copy link
Author

kaydxh commented Dec 1, 2022

Please include full logs (not a screenshot) from clangd -log=verbose -check=some/affected/file.cpp.
Full logs from : clangd -log=verbose -check= /data/home/sea/src/retrieve/cache_loader.cpp

I[00:22:08.194] clangd version 15.0.1 (https://github.com/ycm-core/llvm 708056a3d8259ce1d9fc0f15676d13b53cc23835)
I[00:22:08.194] Features: linux
I[00:22:08.194] PID: 28478
I[00:22:08.194] Working directory: /data/home/sea
I[00:22:08.194] argv[0]: /root/.vim/pack/minpac/start/YouCompleteMe/third_party/ycmd/third_party/clangd/output/bin/clangd
I[00:22:08.194] argv[1]: -log=verbose
I[00:22:08.194] argv[2]: -check=src/retrieve/cache_loader.cpp
V[00:22:08.194] User config file is /root/.config/clangd/config.yaml
I[00:22:08.194] Entering check mode (no LSP server)
I[00:22:08.194] Testing on source file /data/home/sea/src/retrieve/cache_loader.cpp
I[00:22:08.194] Loading compilation database...
I[00:22:08.197] Loaded compilation database from /data/home/sea/compile_commands.json
V[00:22:08.197] Broadcasting compilation database from /data/home/sea
I[00:22:08.197] Compile command from CDB is: /usr/bin/c++ --driver-mode=g++ -DENABLE_POLARIS -DENABLE_RAINBOW -DENABLE_ULS -DENABLE_ZHIYAN -I/data/home/sea/third_path/aio_common/include -I/data/home/sea/third_path/apollo/include -I/data/home/sea/third_path/boost/include -I/data/home/sea/third_path/brpc/include -I/data/home/sea/third_path/cuda/include -I/data/home/sea/third_path/curl/include -I/data/home/sea/third_path/gflags/include -I/data/home/sea/third_path/gif/include -I/data/home/sea/third_path/glog/include -I/data/home/sea/third_path/graphicsMagick/include -I/data/home/sea/third_path/gtest/include -I/data/home/sea/third_path/hiredis/include -I/data/home/sea/third_path/leveldb/include -I/data/home/sea/third_path/libevent/include -I/data/home/sea/third_path/libqos_client/include -I/data/home/sea/third_path/mklml/include -I/data/home/sea/third_path/mysqlclient/include -I/data/home/sea/third_path/opencv/include -I/data/home/sea/third_path/openssl/include -I/data/home/sea/third_path/polaris/include -I/data/home/sea/third_path/protobuf/include -I/data/home/sea/third_path/rainbow/include -I/data/home/sea/third_path/rapid1vn/include -I/data/home/sea/third_path/rapidjson/include -I/data/home/sea/third_path/snappy/include -I/data/home/sea/third_path/xflog/include -I/data/home/sea/third_path/yt_face_search/include -I/data/home/sea/third_path/yun_uls_client/include -I/data/home/sea/third_path/zhiyan_monitor/include -I/data/home/sea/src/proto -I/data/home/sea/src/proto/public -I/data/home/sea/src/proto/services -I/data/home/sea/src -mfpmath=both -g3 -ggdb -fPIC -rdynamic -msse -msse2 -msse3 -msse4.1 -mavx -mavx2 -Wall -Werror -Wextra -Wno-unused-variable -Wno-sign-compare -Wno-unused-function -Wno-unused-local-typedefs -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unknown-pragmas -DNGX_DEBUG -D__const__= -DBRPC_WITH_GLOG=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -DMAGICKCORE_HDRI_ENABLE=1 -DRAPIDJSON_HAS_STDSTRING=1 -fpermissive -Wl,--eh-frame-hdr -faligned-new -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -g -w -o CMakeFiles/retrieve_server.dir/cache_loader.cpp.o -c -resource-dir=/root/.vim/pack/minpac/start/YouCompleteMe/third_party/ycmd/third_party/clangd/output/lib/clang/15.0.1 -- /data/home/sea/src/retrieve/cache_loader.cpp
I[00:22:08.197] Giving up on broadcasting CDB, as we're shutting down
I[00:22:08.198] Parsing command...
I[00:22:08.199] internal (cc1) args are: -cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name cache_loader.cpp -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mfpmath both -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -target-feature +sse -target-feature +sse2 -target-feature +sse3 -target-feature +sse4.1 -target-feature +avx -target-feature +avx2 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -fcoverage-compilation-dir=/data/home/sea/build/src/retrieve -resource-dir /root/.vim/pack/minpac/start/YouCompleteMe/third_party/ycmd/third_party/clangd/output/lib/clang/15.0.1 -D ENABLE_POLARIS -D ENABLE_RAINBOW -D ENABLE_ULS -D ENABLE_ZHIYAN -I /data/home/sea/third_path/aio_common/include -I /data/home/sea/third_path/apollo/include -I /data/home/sea/third_path/boost/include -I /data/home/sea/third_path/brpc/include -I /data/home/sea/third_path/cuda/include -I /data/home/sea/third_path/curl/include -I /data/home/sea/third_path/gflags/include -I /data/home/sea/third_path/gif/include -I /data/home/sea/third_path/glog/include -I /data/home/sea/third_path/graphicsMagick/include -I /data/home/sea/third_path/gtest/include -I /data/home/sea/third_path/hiredis/include -I /data/home/sea/third_path/leveldb/include -I /data/home/sea/third_path/libevent/include -I /data/home/sea/third_path/libqos_client/include -I /data/home/sea/third_path/mklml/include -I /data/home/sea/third_path/mysqlclient/include -I /data/home/sea/third_path/opencv/include -I /data/home/sea/third_path/openssl/include -I /data/home/sea/third_path/polaris/include -I /data/home/sea/third_path/protobuf/include -I /data/home/sea/third_path/rainbow/include -I /data/home/sea/third_path/rapid1vn/include -I /data/home/sea/third_path/rapidjson/include -I /data/home/sea/third_path/snappy/include -I /data/home/sea/third_path/xflog/include -I /data/home/sea/third_path/yt_face_search/include -I /data/home/sea/third_path/yun_uls_client/include -I /data/home/sea/third_path/zhiyan_monitor/include -I /data/home/sea/src/proto -I /data/home/sea/src/proto/public -I /data/home/sea/src/proto/services -I /data/home/sea/src -D NGX_DEBUG -D __const__= -D BRPC_WITH_GLOG=1 -D MAGICKCORE_QUANTUM_DEPTH=16 -D MAGICKCORE_HDRI_ENABLE=1 -D RAPIDJSON_HAS_STDSTRING=1 -D _GLIBCXX_USE_CXX11_ABI=0 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/backward -internal-isystem /root/.vim/pack/minpac/start/YouCompleteMe/third_party/ycmd/third_party/clangd/output/lib/clang/15.0.1/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wall -Werror -Wextra -Wno-unused-variable -Wno-sign-compare -Wno-unused-function -Wno-unused-local-typedefs -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unknown-pragmas -w -std=c++11 -fdeprecated-macro -fdebug-compilation-dir=/data/home/sea/build/src/retrieve -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -faligned-allocation -no-round-trip-args -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ /data/home/sea/src/retrieve/cache_loader.cpp
I[00:22:08.199] Building preamble...
E[00:22:08.199] Could not build a preamble for file /data/home/sea/src/retrieve/cache_loader.cpp version null: CreateTargetInfo() return null
E[00:22:08.199] Failed to build preamble

Could you find any cue from the log?
Thanks!@sam-mccall

@sam-mccall
Copy link
Member

The problem is clang -mfpmath=both , which clang doesn't recognize and treats as a fatal error.

You can remove this from your compile flags either in your build system or by adding a clangd config file: https://clangd.llvm.org/config#remove

It's unfortunate that we're not managing to report this in some discoverable way.
(In this case, we fail to create the target info => no preamble => no preambledata => diags just get thrown away)

@sam-mccall
Copy link
Member

Filed #1408 for the lack of error reporting.

Unfortunately I'm not sure there's much else to do here, it's hard to know which completely unknown flags are critical.

If -mfpmath=both is an important flag (GCC still says it is "experimental") you can consider requesting clang support it in llvm/llvm-project.

sam-mccall added a commit to llvm/llvm-project that referenced this issue Dec 1, 2022
Really we want these to be shown to the client, but the path to do so involves
storing them in

Bandaid for clangd/clangd#1408
See clangd/clangd#1399 for motivation

Differential Revision: https://reviews.llvm.org/D139088
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants