cquery icon indicating copy to clipboard operation
cquery copied to clipboard

some g++ flags cause cquery to fail

Open thorbenk opened this issue 6 years ago • 3 comments

I'm using cquery on a project with a compilation database written for g++ 7.3. In the cquery log, I'm getting libclang had ast read error for... Please try running the following, identify which flag causes the issue, and report a bug.

The output is:

g++: error: unrecognized command line option ‘-working-directory=/work/project’
g++: error: unrecognized command line option ‘-resource-dir=/home/kroeger/thirdparty/cquery/build/clang+llvm-6.0.1-x86_64-linux-gnu-ubuntu-16.04/lib/clang/6.0.1’
g++: error: unrecognized command line option ‘-fparse-all-comments’

Some details about my configuration: I've enabled logging via

"cquery.launch.args": ["--log-file", "/work/cquery-files/project/cquery.log", "--log-all-to-stderr"]

I'm using cquery built from trunk commit 3ac1ff24be1936cc9bea335f3a438d84e365be2f

thorbenk avatar Aug 03 '18 10:08 thorbenk

If you edit your compile_commands.json folder to have clang instead of g++, does that fix the issue? I wonder if using g++ as the compiler driver when invoking libclang is causing issues.

jacobdufault avatar Aug 06 '18 17:08 jacobdufault

Nope, and I think it's a regression because I had the exact same issue in #656 which was then fixed, but apparently it's broken again now.

YaLTeR avatar Aug 14 '18 10:08 YaLTeR

I found this issue while searching for the cause for my problems (see below). I also have a setup where /usr/bin/c++ links to usr/bin/g++ (via /etc/alternatives/c++). In my case, the suggestion above to manually edit compile_commands.json and replace c++ with clang in all command sections helped. After the edit, cquery now correctly resolves all includes.

c++: error: unrecognized command line option ‘-working-directory=/home/USERNAME/WORK_DIR’
c++: error: unrecognized command line option ‘-resource-dir=/home/USERNAME/tools/cquery/build/clang+llvm-6.0.1-x86_64-linux-gnu-ubuntu-14.04/lib/clang/6.0.1’
c++: error: unrecognized command line option ‘-fparse-all-comments’; did you mean ‘--warn-no-comments’?
c++: error: unrecognized command line option ‘-fspell-checking’; did you mean ‘-fno-checking’?

Edit for additional information: i just checked out cquery yesterday, so I'm on commit https://github.com/cquery-project/cquery/commit/32005b79018cdfc50262bfdb54d24ffafa19b88d.

philip-n avatar Sep 03 '18 17:09 philip-n