Andersbakken / rtags

A client/server indexer for c/c++/objc[++] with integration for Emacs based on clang.
http://www.rtags.net
GNU General Public License v3.0
1.83k stars 253 forks source link

Performing Test LIBCLANG_COMPILES - Failed #1350

Closed Pouya-moh closed 5 years ago

Pouya-moh commented 5 years ago

Hi. I know this issue has been emerged multiple times but none of them solved the problem.

I cloned the master, made a build directory and from there:

cmake -DCMAKE_CXX_COMPILER=/usr/local/bin/clang++ -DCMAKE_C_COMPILER=/usr/local/bin/clang ..

The following outcome is similar when I call the the cmake without C and CXX flags. Either way I get this

-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- llvm-config executable found: /usr/local/bin/llvm-config
-- Using Clang version 8.0.0 from /usr/local/lib with CXXFLAGS -I/usr/local/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-- Found LibClang: /usr/local/lib/libclang.so  
-- Performing Test LIBCLANG_COMPILES
-- Performing Test LIBCLANG_COMPILES - Failed
CMake Error at src/CMakeLists.txt:88 (message):
  Failed to compile small clang test app.

  It's likely that the include file <clang-c/Index.h> could not be found!

  Maybe you need to install the clang development package (delete the
  CMakeCache.txt file before trying to run cmake again after installation)?

  See CMakeFiles/CMakeError.log for more info.

-- Configuring incomplete, errors occurred!
See also "/tmp/rtags/build/CMakeFiles/CMakeOutput.log".
See also "/tmp/rtags/build/CMakeFiles/CMakeError.log".

The CMakeFiles/CMakeError.log suggests that /usr/bin/ld: cannot find -lxml2:

Performing C++ SOURCE FILE Test LIBCLANG_COMPILES failed with the following output:
Change Dir: /tmp/rtags/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_f1bd2/fast"
/usr/bin/make -f CMakeFiles/cmTC_f1bd2.dir/build.make CMakeFiles/cmTC_f1bd2.dir/build
make[1]: Entering directory '/tmp/rtags/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_f1bd2.dir/src.cxx.o
/usr/local/bin/clang++    -I/usr/local/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DLIBCLANG_COMPILES  -I/usr/local/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
Linking CXX executable cmTC_f1bd2
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f1bd2.dir/link.txt --verbose=1
/usr/local/bin/clang++   -I/usr/local/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DLIBCLANG_COMPILES  -I/usr/local/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
/usr/bin/ld: cannot find -lxml2
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
CMakeFiles/cmTC_f1bd2.dir/build.make:98: recipe for target 'cmTC_f1bd2' failed
make[1]: *** [cmTC_f1bd2] Error 1
make[1]: Leaving directory '/tmp/rtags/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_f1bd2/fast' failed
make: *** [cmTC_f1bd2/fast] Error 2

However, from the first cmake call, I know it uses -- llvm-config executable found: /usr/local/bin/llvm-config and:

$ /usr/local/bin/llvm-config --system-libs
-lz -lrt -ldl -ltinfo -lpthread -lm -lxml2

In other words, llvm-config knows the libraries but somehow when building the test they cannot be linked.

I have few guesses. The https://github.com/Andersbakken/rtags/issues/493#issuecomment-151894344 suggests that multiple llvm installation could cause problems and I do indeed have multiple ones:

$ dpkg --get-selections | grep -i 'libclang'
libclang-8-dev                  install
libclang-common-8-dev               install
libclang1-8                 install

$ dpkg --get-selections | grep -i 'llvm'
libllvm6.0:amd64                install
libllvm7:amd64                  install
libllvm7:i386                   install
libllvm8:amd64                  install
libllvm8:i386                   install
llvm-8                      install
llvm-8-dev                  install
llvm-8-runtime                  install

Similarly, I have two clang-c/Index.h at

/usr/local/include/clang-c/Index.h
/usr/lib/llvm-8/include/clang-c/Index.h

and two llvm-config:

/usr/local/bin/llvm-config
/usr/lib/llvm-8/bin/llvm-config

Cmake tells me it uses the first which knows about -lxml2 as well, however, calling the second one from command line with --system-libs returns nothing.

Could this be the source of the problem? If so how can I fix it? If not, what else can I try?

Thanks a lot and cheers!

Pouya-moh commented 5 years ago

It seems that the problem is libxml12-dev is needed. Installing it solved the problem. With that said, IMO, given that there are so many issues regarding the compilation of the test, it might be necessary to revise/reframe/rewrite/etc the test and the accompanying documentation.