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

Syntax checker parser fails when compile options contains "-include" #277

Closed
sezaru opened this issue Jan 28, 2016 · 5 comments
Closed

Syntax checker parser fails when compile options contains "-include" #277

sezaru opened this issue Jan 28, 2016 · 5 comments

Comments

@sezaru
Copy link

sezaru commented Jan 28, 2016

Hello there,

When opening the rtags project on emacs, irony syntax checker will fail to parse it's compile options, resulting in the error:
Error from syntax checker irony: parsing failed

Any file will get the same error, but for this example I used the file ClangIndexer.cpp, the irony server will return this compile options from it:

~/irony-server/build $ ./src/irony-server get-compile-options /home/devel/rtags/build
  /home/devel/rtags/src/ClangIndexer.cpp

execute: Command{action=Command::GetCompileOptions,
                 file='/home/devel/rtags/src/ClangIndexer.cpp',
                 dir='/home/devel/rtags/build', line=0, column=0, flags=[],
                 unsavedFiles.count=0, opt=off}
(
(("/usr/bin/c++" "-DCLANG_LIBDIR=/usr/lib/llvm-3.6/lib" "-DOS_Linux" "-DRCT_HAVE_OPENSSL"
  "-DRCT_HAVE_ZLIB" "-I/usr/lib/llvm-3.6/include" "-D_GNU_SOURCE" "-D__STDC_CONSTANT_MACROS"
  "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-Wall" "-Wextra" "-Wpointer-arith"
  "-Wnon-virtual-dtor" "-fno-rtti" "-std=c++11" "-Wall" "-Wextra" "-Wpointer-arith"
  "-Wnon-virtual-dtor" "-fno-rtti" "-std=c++11" "-Wstrict-aliasing=2" "-fno-exceptions"
  "-Wcast-qual" "-fPIC" "-fstack-protector-all" "-Wstack-protector" "-O3" "-DNDEBUG"
  "-I/home/devel/rtags/src" "-I/home/devel/rtags/src/rct"
  "-I/home/devel/rtags/build/src/include" "-Winvalid-pch" "-include"
  "/home/devel/rtags/build/src/cotire/rtags_CXX_prefix.hxx" "-o"
  "CMakeFiles/rtags.dir/ClangIndexer.cpp.o" "-c" "/home/devel/rtags/src/ClangIndexer.cpp" )
  . "/home/devel/rtags/build/src")
)

;;EOT

The problem that makes the error occurs is this option:

"-include" "/home/devel/rtags/build/src/cotire/rtags_CXX_prefix.hxx"

If I remove it from my compile options the parser works just fine.

@Sarcasm
Copy link
Owner

Sarcasm commented Jan 28, 2016

Just to be sure, does the file actually exist?
It seems to be a build generated file, as such it may not exist until before the first build.

Are you able to reproduce it with a minimal example?

@sezaru
Copy link
Author

sezaru commented Jan 28, 2016

The file exists in the build directory.

I didn't created a small example since it was occurring in the rtags source code, but I will try to create one and post here

@sezaru
Copy link
Author

sezaru commented Jan 29, 2016

The small project is in this link as promissed, when running cmake + make, the files will be created inside cotire directory, and irony will start to fail to parse it

https://www.dropbox.com/s/duko3u3gn75z9ed/test_irony.tar.bz2?dl=0

@Sarcasm
Copy link
Owner

Sarcasm commented Jan 30, 2016

Ok, it seems the issue is not with -include but more about precompiled headers.

I can get irony-mode to work if I generate the compile_commands.json for Clang:

env CC=clang CXX=clang++ cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

But the compile commands for gcc don't work:

cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../

And I think it makes sense. The precompiled headers are often a compiler-specific internal representation of the code. So even if Clang is mostly compatible with GCC, it does not support GCC precompiled headers.

I used the following command to know that:

clang++ -fsyntax-only -Qunused-arguments -I../minimal_example -I../include -Winvalid-pch -include /home/papin_g/Downloads/test_irony_gcc/build/cotire/minimal_example_CXX_prefix.hxx ~/Downloads/test_irony_gcc/src/main.cpp
error: input is not a PCH file:
      '/home/papin_g/Downloads/test_irony_gcc/build/cotire/minimal_example_CXX_prefix.hxx.gch'
fatal error: '/home/papin_g/Downloads/test_irony_gcc/build/cotire/minimal_example_CXX_prefix.hxx.gch' does not appear
      to be a precompiled header file
2 errors generated.

@sezaru
Copy link
Author

sezaru commented Jan 30, 2016

Thanks, that really fix it, will close the issue since the origin of it is outside irony.

@sezaru sezaru closed this as completed Jan 30, 2016
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

2 participants