Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
901 stars 98 forks source link

Fedora 28: clang++ is not used by cmake, and c++ is not working #484

Open Dav1d23 opened 6 years ago

Dav1d23 commented 6 years ago

I had an issue compiling the irony-server on fedora 28 with clang6.

Basically, this command is not working at first.

cmake --clean-first -DCMAKE_INSTALL_PREFIX\=~/.emacs.d/irony/ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ~/.emacs.d/elpa/irony-20180519.422/server && cmake --build . --use-stderr --config Release --target install

First issue: CLANG_RESOURCE_DIR is not detected, so you should force it using -DCLANG_RESOURCE_DIR=/usr/lib64/clang/6.0.0/

Then, compilation is not working fine. bB debugging the command line, I saw that c++ was used instead of clang++. Just running this line in the cmake folder $ clang++ -fno-exceptions -O2 -DNDEBUG -rdynamic CMakeFiles/irony-server.dir/support/CommandLineParser.cpp.o CMakeFiles/irony-server.dir/support/TemporaryFile.cpp.o CMakeFiles/irony-server.dir/Command.cpp.o CMakeFiles/irony-server.dir/Irony.cpp.o CMakeFiles/irony-server.dir/TUManager.cpp.o CMakeFiles/irony-server.dir/main.cpp.o -o ../bin/irony-server -lclang and re-running the whole cmake install target above solved the issue.

Is it normal? Am I missing anything? Is there anything that can be done to avoid this situation?

Sarcasm commented 6 years ago

This does not look normal.

Can you show the output of a simple invocation like:

mkdir build
cd build
cmake ../server
Dav1d23 commented 6 years ago

This is what I got.

~/.emacs.d/elpa/irony-20180519.422/server/build $ cmake .. 
-- The C compiler identification is GNU 8.0.1
-- The CXX compiler identification is GNU 4.9.4
-- Check for working C compiler: /usr/lib64/ccache/cc
-- Check for working C compiler: /usr/lib64/ccache/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/lib64/ccache/c++
-- Check for working CXX compiler: /usr/lib64/ccache/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'Release' as none was specified
-- Performing Test HAS_STDCXX11
-- Performing Test HAS_STDCXX11 - Success
-- Performing Test HAS_CXX11_STDLIB
-- Performing Test HAS_CXX11_STDLIB - Success
-- C++11 compiler option(s): -std=c++11
-- Found LibClang: /usr/lib64/libclang.so  
-- Detecting Clang resource directory
-- Detecting Clang resource directory -- fail
CMake Warning at cmake/CheckClangResourceDir.cmake:77 (message):
  CheckClangResourceDir: failed to compile checker, please report.

    Compile output:
      Change Dir: /home/david/.emacs.d/elpa/irony-20180519.422/server/build/CMakeFiles/CMakeTmp

  Run Build Command:"/usr/bin/gmake" "cmTC_99cd5/fast"

  /usr/bin/gmake -f CMakeFiles/cmTC_99cd5.dir/build.make
  CMakeFiles/cmTC_99cd5.dir/build

  gmake[1]: Entering directory
  '/home/david/dev/dotfiles/.emacs.d/elpa/irony-20180519.422/server/build/CMakeFiles/CMakeTmp'

  Building CXX object
  CMakeFiles/cmTC_99cd5.dir/LibClangDiagnosticsChecker.cpp.o

  /usr/lib64/ccache/c++ -fno-exceptions -o
  CMakeFiles/cmTC_99cd5.dir/LibClangDiagnosticsChecker.cpp.o -c
  /home/david/.emacs.d/elpa/irony-20180519.422/server/build/CMakeFiles/CMakeTmp/LibClangDiagnosticsChecker.cpp

  Linking CXX executable cmTC_99cd5

  /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_99cd5.dir/link.txt
  --verbose=1

  /usr/lib64/ccache/c++ -fno-exceptions -rdynamic
  CMakeFiles/cmTC_99cd5.dir/LibClangDiagnosticsChecker.cpp.o -o cmTC_99cd5
  /usr/lib64/libclang.so

  /usr/lib64/../lib64/libclangTooling.so.6: undefined reference to `vtable
  for std::__cxx11::basic_stringbuf<char, std::char_traits<char>,
  std::allocator<char> >@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangIncludeFixerPlugin.so.6: undefined reference to
  `__cxa_init_primary_exception@CXXABI_1.3.11'

  /usr/lib64/../lib64/libclangFrontend.so.6: undefined reference to `typeinfo
  for std::_V2::error_category@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangIncludeFixerPlugin.so.6: undefined reference to
  `std::__atomic_futex_unsigned_base::_M_futex_notify_all(unsigned
  int*)@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangIncludeFixerPlugin.so.6: undefined reference to
  `std::thread::_State::~_State()@GLIBCXX_3.4.22'

  /usr/lib64/../lib64/libLLVM-6.0.so: undefined reference to
  `std::basic_istream<char, std::char_traits<char> >& std::operator>><char,
  std::char_traits<char>, std::allocator<char> >(std::basic_istream<char,
  std::char_traits<char> >&, std::__cxx11::basic_string<char,
  std::char_traits<char>, std::allocator<char> >&)@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangFrontend.so.6: undefined reference to
  `std::_V2::error_category::equivalent(int, std::error_condition const&)
  const@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangTooling.so.6: undefined reference to
  `std::__cxx11::basic_stringstream<char, std::char_traits<char>,
  std::allocator<char> >::~basic_stringstream()@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangFrontend.so.6: undefined reference to
  `std::_V2::error_category::_M_message[abi:cxx11](int) const@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangIncludeFixerPlugin.so.6: undefined reference to
  `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
  std::default_delete<std::thread::_State> >, void (*)())@GLIBCXX_3.4.22'

  /usr/lib64/../lib64/libclangIncludeFixerPlugin.so.6: undefined reference to
  `std::__exception_ptr::exception_ptr::exception_ptr(void*)@CXXABI_1.3.11'

  /usr/lib64/libclang.so: undefined reference to
  `std::_V2::system_category()@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangTooling.so.6: undefined reference to `vtable
  for std::__cxx11::basic_stringstream<char, std::char_traits<char>,
  std::allocator<char> >@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/../lib64/../lib64/libclangStaticAnalyzerCore.so.6:
  undefined reference to `std::__cxx11::basic_ostringstream<char,
  std::char_traits<char>, std::allocator<char>
  >::~basic_ostringstream()@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libLLVM-6.0.so: undefined reference to
  `std::__future_base::_State_baseV2::_Make_ready::_M_set()@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangFrontend.so.6: undefined reference to
  `std::basic_istream<char, std::char_traits<char> >& std::getline<char,
  std::char_traits<char>, std::allocator<char> >(std::basic_istream<char,
  std::char_traits<char> >&, std::__cxx11::basic_string<char,
  std::char_traits<char>, std::allocator<char> >&, char)@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libLLVM-6.0.so: undefined reference to
  `std::__cxx11::basic_stringbuf<char, std::char_traits<char>,
  std::allocator<char> >::str() const@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangTooling.so.6: undefined reference to `VTT for
  std::__cxx11::basic_stringstream<char, std::char_traits<char>,
  std::allocator<char> >@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangIncludeFixerPlugin.so.6: undefined reference to
  `typeinfo for std::thread::_State@GLIBCXX_3.4.22'

  /usr/lib64/../lib64/../lib64/libclangAnalysis.so.6: undefined reference to
  `std::__cxx11::basic_stringstream<char, std::char_traits<char>,
  std::allocator<char>
  >::basic_stringstream(std::_Ios_Openmode)@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangFrontend.so.6: undefined reference to
  `std::_V2::error_category::~error_category()@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangFrontend.so.6: undefined reference to
  `std::_V2::error_category::default_error_condition(int)
  const@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangBasic.so.6: undefined reference to
  `std::_V2::generic_category()@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libLLVM-6.0.so: undefined reference to `vtable for
  std::__cxx11::basic_ostringstream<char, std::char_traits<char>,
  std::allocator<char> >@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangIncludeFixerPlugin.so.6: undefined reference to
  `std::logic_error::logic_error(std::logic_error const&)@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangFrontend.so.6: undefined reference to
  `std::_V2::error_category::equivalent(std::error_code const&, int)
  const@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/../lib64/libclangIncludeFixer.so.6: undefined reference
  to `std::__atomic_futex_unsigned_base::_M_futex_wait_until(unsigned int*,
  unsigned int, bool, std::chrono::duration<long, std::ratio<1l, 1l> >,
  std::chrono::duration<long, std::ratio<1l, 1000000000l> >)@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libLLVM-6.0.so: undefined reference to `VTT for
  std::__cxx11::basic_ostringstream<char, std::char_traits<char>,
  std::allocator<char> >@GLIBCXX_3.4.21'

  /usr/lib64/../lib64/libclangIncludeFixerPlugin.so.6: undefined reference to
  `std::logic_error::logic_error(std::__cxx11::basic_string<char,
  std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'

  collect2: error: ld returned 1 exit status

  gmake[1]: *** [CMakeFiles/cmTC_99cd5.dir/build.make:88: cmTC_99cd5] Error 1

  gmake[1]: Leaving directory
  '/home/david/dev/dotfiles/.emacs.d/elpa/irony-20180519.422/server/build/CMakeFiles/CMakeTmp'

  gmake: *** [Makefile:126: cmTC_99cd5/fast] Error 2

Call Stack (most recent call first):
  src/CMakeLists.txt:8 (check_clang_resource_dir)

-- Irony package version is '1.2.0'
-- Found emacs: /usr/local/bin/emacs
-- Configuring done
-- Generating done
-- Build files have been written to: /home/david/.emacs.d/elpa/irony-20180519.422/server/build