Giter VIP home page Giter VIP logo

Comments (2)

MaskRay avatar MaskRay commented on July 29, 2024

2019-07-06-001628_448x629_scrot
2019-07-06-001638_388x112_scrot

Please paste text, not images.

mkdir build && cd build && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=YES .. && ln -s compile_commands.json

Tip:

cmake -H. -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

to avoid cd

Here are some things you should try before filing a bug report:

If none of those help, remove this section and fill out the four sections in the template below.


Observed behavior

Describe what happened. Any aids you can include (that you think could be relevant) are a tremendous help.

  • compile_commands.json or .ccls (wiki/Project-Setup)
  • Reduce to A minimal set of .c .cc .h .hh files that can still demonstrate the issue.
  • Consider a screencast gif.

Expected behavior

Describe what you expected to happen.

Steps to reproduce

  1. Select these example steps,
  2. Delete them,
  3. And replace them with precise steps to reproduce your issue.

System information

  • ccls version (git describe --tags --long):
  • clang version:
  • OS:
  • Editor:
  • Language client (and version):

from emacs-ccls.

cosven avatar cosven commented on July 29, 2024

I've met the exact same phenomenon, and I solved it by adjusting the compiler flags.

TL;DR, I find the lsp server will work as long as the project can be built with clang(note: working with gcc does not state that the project will work with clang).


long long story below

I record my experience here in case people may meet the same problem. Note, I'm new to c++ and c++ build system.

My System Environment

I have a system(centos 7.6), which installed devtoolset-7(gcc 7).
I also compile and install clang 11 by myself.

My Project Info

I try to use ccls on https://github.com/tikv/titan project.

After I run

cmake -H. -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
ln -sf build/compile_commands.json .

I can see the compiler_commands.json, and the first several lines looks like this

โ˜ ~/p/titan ๎‚ master* > head -6 compile_commands.json
[
{
  "directory": "/root/xxx/titan/build",
  "command": "/opt/rh/devtoolset-7/root/usr/bin/c++  .............. -W -Wextra -Wall -Wsign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -Wno-strict-aliasing -std=c++11 -fno-omit-frame-pointer -momit-leaf-frame-pointer -march=native -Werror -fno-builtin-memcmp   -o CMakeFiles/titan_blob_file_iterator_test.dir/src/blob_file_iterator_test.cc.o -c /root/xxx/titan/src/blob_file_iterator_test.cc",
  "file": "/root/xxx/titan/src/blob_file_iterator_test.cc"
},

And I try to start my Emacs and open the project, but it does not work, and the lsp server(ccls) always responds with not indexed. And if I remove the compiler_commands.json, it works partially(some header file can't be found by lsp server).

I'm pretty sure that there are some problems in my json file, however, I do not know where the problem is (I think the root cause is that I do not know the working mechanism of ccls and I have little knowledge about c++).

After long time searching, I decide to try clangd to see if it can work properly, but of course, it failed. And the error message I found from the clangd:: stderr is Couldn't build compiler instance.

I search the error message in clangd source code and I found the reason this happens is that the compiler should be clang instead of gcc. So I disable my gcc and try to re-build my project with clang, to my surprise, the build-process failed. After some investigation, I adjust some compile flags and the project can be built with clang.

cmake -H. -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=ON  -DPORTABLE=1

After that, the lsp server also works ๐Ÿ™ˆ.

I change the lsp server from clangd to ccls, and it also works well.

from emacs-ccls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.