[162/4396] Linking CXX executable bin/llvm-tblgen Failed: : && /usr/local/bin/clang++ -stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Werror=date-time -std=c++11 -fcolor-diagnostics -ffunction-sections -fdata-sections -O3 -DNDEBUG -lc++ -lc++abi -Wl,-allow-shlib-undefined -Wl,-O3 -Wl,--gc-sections utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/AsmMatcherEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/AsmWriterEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/AsmWriterInst.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/Attributes.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CallingConvEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeEmitterGen.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenDAGPatterns.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenInstruction.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenMapTable.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenRegisters.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenSchedule.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenTarget.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DAGISelEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DAGISelMatcherEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DAGISelMatcherGen.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DAGISelMatcherOpt.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DAGISelMatcher.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DFAPacketizerEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DisassemblerEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/FastISelEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/FixedLenDecoderEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/InstrInfoEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/IntrinsicEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/OptParserEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/PseudoLoweringEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/RegisterInfoEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/SearchableTableEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/SubtargetEmitter.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/TableGen.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86DisassemblerTables.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86ModRMFilters.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86RecognizableInstr.cpp.o utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CTagsEmitter.cpp.o -o bin/llvm-tblgen lib/libLLVMSupport.a lib/libLLVMTableGen.a -lpthread lib/libLLVMSupport.a -lrt -ldl -ltinfo -lpthread -lz -lm lib/libLLVMDemangle.a -Wl,-rpath,"\$ORIGIN/../lib" && : utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DFAPacketizerEmitter.cpp.o: In function `(anonymous namespace)::DFAPacketizerEmitter::run(llvm::raw_ostream&)': /home/mehrlich/Code/llvm/llvm/utils/TableGen/DFAPacketizerEmitter.cpp:(.text._ZN12_GLOBAL__N_120DFAPacketizerEmitter3runERN4llvm11raw_ostreamE+0x253f): undefined reference to `std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char>::~basic_string()' clang-4.0: error: linker command Failed with exit code 1 (use -v to see invocation) [162/4396] Building CXX object lib/MC/CMakeFiles/LLVMMC.dir/MCContext.cpp.o ninja: build stopped: subcommand Failed.
相关错误是未定义的符号:
在函数(匿名命名空间):: DFAPacketizerEmitter :: run(llvm :: raw_ostream&)’:/ home / mehrlich / Code /llvm / _llvm / utils / TableGen / DFFacketizerEmitter.cpp:(.text._ZN12_GLOBAL__N_120DFAPacketizerEmitter3runERN4llvm11raw_ostreamE 0x253f):undefined reference to std :: __ 1 :: basic_string< char,std :: __ 1 :: char_traits< char> ;,std :: __ 1 :: allocator< char> :: ~basic_string()’
据推测,这是出于以下两个原因之一:
1. Clang正在使用libstdc标头:
我们可以从失败的命令中看到clang正确地选择-stdlib = libc开关.正在运行%clang –stdlib = libc -E -x c – -v< / dev / null检查带有此选项的默认包含路径
clang version 4.0.0 (trunk 281213) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/local/bin Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.4.0 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6 Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.0.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0 Candidate multilib: .;@m64 Selected multilib: .;@m64 Found CUDA installation: /usr/local/cuda,version 7.5 "/usr/local/bin/clang-4.0" -cc1 -triple x86_64-unknown-linux-gnu -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/local/bin/../lib/clang/4.0.0 -internal-isystem /usr/local/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /usr/local/bin/../lib/clang/4.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/mehrlich/Code/llvm/build -ferror-limit 19 -fmessage-length 343 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o - -x c++ - clang -cc1 version 4.0.0 based upon LLVM 4.0.0svn default target x86_64-unknown-linux-gnu ignoring nonexistent directory "/include" #include "..." search starts here: #include <...> search starts here: /usr/local/bin/../include/c++/v1 /usr/local/include /usr/local/bin/../lib/clang/4.0.0/include /usr/include/x86_64-linux-gnu /usr/include End of search list. # 1 "<stdin>" # 1 "<built-in>" 1 # 1 "<built-in>" 3 # 328 "<built-in>" 3 # 1 "<command line>" 1 # 1 "<built-in>" 2 # 1 "<stdin>" 2
第一个标题搜索路径#include< ...>搜索从这里开始:/usr/local/bin/../include/c / v1是libc头文件的正确位置.所以我非常怀疑是这个
2. Clang没有链接libc
将选项-lc -lc abi添加到CMAKE_EXE_LINKER_FLAGS,CMAKE_SHARED_LINKER_FLAGS,CMAKE_MODULE_LINKER_FLAGS和CMAKE_STATIC_LINKER_FLAGS会出现以下错误:
[65/4396] Linking CXX static library lib/libLLVMDemangle.a Failed: : && /usr/bin/cmake -E remove lib/libLLVMDemangle.a && /usr/bin/ar qc lib/libLLVMDemangle.a -lc++ -lc++abi lib/Demangle/CMakeFiles/LLVMDemangle.dir/ItaniumDemangle.cpp.o && /usr/bin/ranlib lib/libLLVMDemangle.a && : /usr/bin/ar: invalid option -- '+' Usage: /usr/bin/ar [emulation options] [-]{dmpqrstx}[abcDfilMNoPsSTuvV] [--plugin <name>] [member-name] [count] archive-file file... /usr/bin/ar -M [<mri-script] commands: d - delete file(s) from the archive m[ab] - move file(s) in the archive p - print file(s) found in the archive q[f] - quick append file(s) to the archive r[ab][f][u] - replace existing or insert new file(s) into the archive s - act as ranlib t - display contents of archive x[o] - extract file(s) from the archive command specific modifiers: [a] - put file(s) after [member-name] [b] - put file(s) before [member-name] (same as [i]) [D] - use zero for timestamps and uids/gids (default) [U] - use actual timestamps and uids/gids [N] - use instance [count] of name [f] - truncate inserted file names [P] - use full path names when matching [o] - preserve original dates [u] - only replace files that are newer than current archive contents generic modifiers: [c] - do not warn if the library had to be created [s] - create an archive index (cf. ranlib) [S] - do not build a symbol table [T] - make a thin archive [v] - be verbose [V] - display the version number @<file> - read options from <file> --target=BFDNAME - specify the target object format as BFDNAME optional: --plugin <p> - load the specified plugin emulation options: No emulation specific options /usr/bin/ar: supported targets: elf64-x86-64 elf32-i386 elf32-iamcu elf32-x86-64 a.out-i386-linux pei-i386 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big pe-x86-64 pe-bigobj-x86-64 pe-i386 plugin srec symbolsrec verilog tekhex binary ihex
我们可以看到,链接器选项被cmake传递给/usr/bin/ar用于静态库(这对我来说似乎是错误的,但我不是构建过程的专家,所以我可能会错误).从CMAKE_STATIC_LINKER_FLAGS中删除这些选项将恢复为有关未定义符号的原始错误消息,因此可能llvm-tblgen目标是静态库. llvm-tblgen绝对是一个可执行文件,不确定CMAKE_EXE_LINKER_FLAGS是否正在应用它正在应用标志,这意味着我不知道为什么这不会起作用…
在这一点上,我不确定这是谁的错,我的,铿锵声或cmake,但如果有人对这个过程有任何建议或专业知识,我会很感激帮助.
更新
现在错误在compiler-rt中:
projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_unwind_linux_libcdep.cc.o: In function `__sanitizer::Unwind_GetIP(_Unwind_Context*)': /home/mehrlich/Code/llvm/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:98: undefined reference to `_Unwind_GetIP' projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_unwind_linux_libcdep.cc.o: In function `Unwind_GetIP': /home/mehrlich/Code/llvm/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:98: undefined reference to `_Unwind_GetIP' projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_unwind_linux_libcdep.cc.o: In function `__sanitizer::BufferedStackTrace::SlowUnwindStack(unsigned long,unsigned int)': /home/mehrlich/Code/llvm/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:125: undefined reference to `_Unwind_Backtrace' projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.x86_64.dir/sanitizer_unwind_linux_libcdep.cc.o: In function `SlowUnwindStack': /home/mehrlich/Code/llvm/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cc:125: undefined reference to `_Unwind_Backtrace'
似乎与此bug有关
解决方法
不幸的是,你的libc安装有问题,需要在构建Clang之前进行更新.您只需在现有安装的顶部安装新的libc即可.这可以使用当前(错误)构建目录中的sudo make install-cxx来完成.然后你可以继续像往常一样建立Clang.
有关构建/安装libc的更多信息,请参阅http://libcxx.llvm.org/docs/BuildingLibcxx.html.
(注意:修复libc安装不应该要求重建LLVM或Clang.)