Closed chrisburel closed 8 years ago
Here's a comparison of the output of nm -C
on the built main.cpp.o file from both Debian sid and Fedora 22:
U clang::tooling::ToolInvocation::ToolInvocation(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, clang::FrontendAction*, clang::FileManager*)
U clang::tooling::ToolInvocation::ToolInvocation(std::vector<std::string, std::allocator<std::string> >, clang::FrontendAction*, clang::FileManager*)
For some reason Debian is writing out std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
instead of just std::string
.
I believe this has something to do with GCC 5 and it's new ABI. See https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
Libclang was probably compiled with the old ABI, but you are compiling mocng with the new ABI. I guess because the libclang package were most likely build with GCC 4.x while you now have GCC 5 on your system.
Where did you get the clang packages? was it from thedebian repository or from the llvm website? Maybe using the packages from the debian repository might help.
Otherwise you can try to add --disable-libstdcxx-dual-abi`: Add this to the src/CMakeLists.txt
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --disable-libstdcxx-dual-abi")
btw, what is the result of llvm-config --cxxflags
?
I'm using the clang packages from llvm website.
std::string
. Here's the unique errors:undefined references to `clang::QualType::getAsString(clang::PrintingPolicy const&) const' follow
undefined reference to `clang::DeclarationName::getAsString() const'
undefined reference to `clang::Lexer::getSpelling(clang::Token const&, clang::SourceManager const&, clang::LangOptions const&, bool*)'
undefined reference to `clang::NamedDecl::getQualifiedNameAsString() const'
undefined reference to `clang::QualType::getAsString(clang::PrintingPolicy const&) const'
undefined reference to `clang::TypoCorrection::getAsString(clang::LangOptions const&) const'
abi:cxx11
link errors. These seem to be methods that return a std::string
, or take one as an argument:undefined references to `clang::QualType::getAsString[abi:cxx11](clang::PrintingPolicy const&) const' follow
undefined reference to `clang::DeclarationName::getAsString[abi:cxx11]() const'
undefined reference to `clang::Lexer::getSpelling[abi:cxx11](clang::Token const&, clang::SourceManager const&, clang::LangOptions const&, bool*)'
undefined reference to `clang::NamedDecl::getQualifiedNameAsString[abi:cxx11]() const'
undefined reference to `clang::QualType::getAsString[abi:cxx11](clang::PrintingPolicy const&) const'
undefined reference to `clang::tooling::ToolInvocation::ToolInvocation(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, clang::FrontendAction*, clang::FileManager*)'
undefined reference to `clang::TypoCorrection::getAsString[abi:cxx11](clang::LangOptions const&) const'
--disable-libstdcxx-dual-abi
to the CXX flags appears to not be supported by g++ (?)[ 5%] Building CXX object src/CMakeFiles/moc.dir/main.cpp.o
cd /home/cburel/src/moc-ng/build/src && /usr/bin/c++ -I/home/cburel/apps/clang-for-15.04/include -I/home/cburel/src/moc-ng/build/src --disable-libstdcxx-dual-abi -std=c++11 -g -Wall -fno-rtti -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -o CMakeFiles/moc.dir/main.cpp.o -c /home/cburel/src/moc-ng/src/main.cpp
cc1plus: error: unknown pass libstdcxx-dual-abi specified in -fdisable
clang
executable seems to also not support the --disable-libstdcxx-dual-abi
(which makes sense, since it is related to the GCC 5 release).Here's the output of llvm-config --cxxflags
for both the debian-provided clang and the clang from the llvm website:
$ ~/apps/clang/bin/llvm-config --cxxflags
-I/home/cburel/apps/clang-for-15.04/include -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3 -fomit-frame-pointer -std=c++11 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fPIC -ffunction-sections -fdata-sections -Wcast-qual
$ /usr/bin/llvm-config-3.6 --cxxflags
-I/usr/lib/llvm-3.6/include -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -g -O2 -fomit-frame-pointer -std=c++11 -fvisibility-inlines-hidden -fno-exceptions -fPIC -ffunction-sections -fdata-sections -Wcast-qual
If I add -D_GLIBCXX_USE_CXX11_ABI=0
to the defines list, then building with the clang driver works. It definitely seems this is not a moc-ng issue, but a clang/gcc5 one.
Just for the record, this stackoverflow qeustion seems to be relevant, and seems to point to an unresolved clang bug.
I'm using clang version 3.6.2, the binary download from clang's website, and Linux debian 4.2.0. I'm using the downloaded clang binary to do the build. I get the following error while linking: