我正在使用LLVM conan package来构建我的编译器,到目前为止,它运行得很好,直到我尝试使用llvm::sys::getDefaultTargetTriple
和llvm::TargetRegistry::lookupTarget
。我得到了对两者的未定义引用。两者似乎都来自LLVM支持库,并且至少llvm::sys::getDefaultTargetTriple
看起来是自动生成的(我在系统上找到了它的.inc
源代码)。Conan似乎告诉CMake在LLVM支持库中进行链接,因为我可以看到,当我尝试构建并获得错误时,它被传递到链接器(例如)-lLLVMSupport
。我看到一些人在过去切换到带有LLVM 3/4的GCC 5时遇到了链接器错误。但这是LLVM-13.0.0和gcc-12.0.1。柯南我看到了warns about C++ ABI compatibility with GCC-5
我改变了我的个人资料的设置,但没有改变(还)。我可能会尝试重建LLVM和更新这篇文章。
我真的需要在几个小时内拿到这个,是吗
1.一种手工知道我的操作系统的三元组字符串应该是什么的方法?我在这里看到了格式。它似乎是基于宏的?gcc -dumpmachine
足够吗?
1.用这个手工生成一个“目标”有多可行,我正在对此进行逆向工程
1.主要问题是,如何修复此错误并链接到llvm::sys::getDefaultTargetTriple
和llvm::TargetRegistry::lookupTarget
下面是完整的日志:
root@3129d254c74c:~/workdir/compilerbuild# ninja warp_compiler
[2/2] Linking CXX executable bin/warp_compiler
FAILED: bin/warp_compiler
: && /usr/bin/c++ CMakeFiles/warp_compiler.dir/Compiler/Compile.cpp.o CMakeFiles/warp_compiler.dir/Compiler/FunctionParser.cpp.o CMakeFiles/warp_compiler.dir/Compiler/Main.cpp.o -o bin/warp_compiler -L/root/.conan/data/cpputest/4.0/_/_/package/7f06ab4d29b1f14af224d13dc05f362c6832ed41/lib -L/root/.conan/data/llvm-core/13.0.0/_/_/package/6efbb14f313e71b5e1dbf77c1c011f47614b7c7c/lib -L/root/.conan/data/libxml2/2.9.10/_/_/package/c4a7cacf01760cbd7354b11a55bf653f7df2bf5d/lib -L/root/.conan/data/zlib/1.2.12/_/_/package/2a19826344ff00be1c04403f2f8e7008ed3a7cc6/lib -L/root/.conan/data/libiconv/1.17/_/_/package/2a19826344ff00be1c04403f2f8e7008ed3a7cc6/lib -Wl,-rpath,/root/.conan/data/cpputest/4.0/_/_/package/7f06ab4d29b1f14af224d13dc05f362c6832ed41/lib:/root/.conan/data/llvm-core/13.0.0/_/_/package/6efbb14f313e71b5e1dbf77c1c011f47614b7c7c/lib:/root/.conan/data/libxml2/2.9.10/_/_/package/c4a7cacf01760cbd7354b11a55bf653f7df2bf5d/lib:/root/.conan/data/zlib/1.2.12/_/_/package/2a19826344ff00be1c04403f2f8e7008ed3a7cc6/lib:/root/.conan/data/libiconv/1.17/_/_/package/2a19826344ff00be1c04403f2f8e7008ed3a7cc6/lib lib/liblibwarp.a -lCppUTestExt -lCppUTest -lLLVMTableGenGlobalISel -lLLVMTableGen -lLLVMFileCheck -lLLVMAArch64AsmParser -lLLVMAArch64CodeGen -lLLVMAArch64Disassembler -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64Utils -lLLVMAMDGPUAsmParser -lLLVMAMDGPUCodeGen -lLLVMMIRParser -lLLVMAMDGPUDisassembler -lLLVMAMDGPUDesc -lLLVMAMDGPUInfo -lLLVMAMDGPUUtils -lLLVMARMAsmParser -lLLVMARMCodeGen -lLLVMARMDisassembler -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMUtils -lLLVMAVRAsmParser -lLLVMAVRCodeGen -lLLVMAVRDesc -lLLVMAVRDisassembler -lLLVMAVRInfo -lLLVMBPFAsmParser -lLLVMBPFCodeGen -lLLVMBPFDesc -lLLVMBPFDisassembler -lLLVMBPFInfo -lLLVMCoverage -lLLVMDWARFLinker -lLLVMDWP -lLLVMDebugInfoGSYM -lLLVMDlltoolDriver -lLLVMFrontendOpenACC -lLLVMFuzzMutate -lLLVMHexagonCodeGen -lLLVMHexagonAsmParser -lLLVMHexagonDisassembler -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMInterfaceStub -lLLVMInterpreter -lLLVMLTO -lLLVMExtensions -lLLVMLanaiCodeGen -lLLVMLanaiAsmParser -lLLVMLanaiDisassembler -lLLVMLanaiDesc -lLLVMLanaiInfo -lLLVMLibDriver -lLLVMOption -lLLVMLineEditor -lLLVMMCA -lLLVMMCJIT -lLLVMMSP430AsmParser -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Disassembler -lLLVMMSP430Info -lLLVMMipsAsmParser -lLLVMMipsCodeGen -lLLVMMipsDesc -lLLVMMipsDisassembler -lLLVMMipsInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMObjectYAML -lLLVMOrcJIT -lLLVMPasses -lLLVMCoroutines -lLLVMipo -lLLVMFrontendOpenMP -lLLVMIRReader -lLLVMAsmParser -lLLVMInstrumentation -lLLVMLinker -lLLVMVectorize -lLLVMObjCARCOpts -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMJITLink -lLLVMOrcTargetProcess -lLLVMOrcShared -lLLVMPowerPCAsmParser -lLLVMPowerPCCodeGen -lLLVMPowerPCDesc -lLLVMPowerPCDisassembler -lLLVMPowerPCInfo -lLLVMRISCVAsmParser -lLLVMRISCVCodeGen -lLLVMRISCVDisassembler -lLLVMRISCVDesc -lLLVMRISCVInfo -lLLVMSparcAsmParser -lLLVMSparcCodeGen -lLLVMSparcDesc -lLLVMSparcDisassembler -lLLVMSparcInfo -lLLVMSymbolize -lLLVMDebugInfoPDB -lLLVMSystemZAsmParser -lLLVMSystemZCodeGen -lLLVMSystemZDisassembler -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMWebAssemblyAsmParser -lLLVMWebAssemblyCodeGen -lLLVMWebAssemblyDisassembler -lLLVMWebAssemblyDesc -lLLVMWebAssemblyInfo -lLLVMWebAssemblyUtils -lLLVMWindowsManifest -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMCFGuard -lLLVMGlobalISel -lLLVMX86Desc -lLLVMX86Disassembler -lLLVMX86Info -lLLVMXCoreCodeGen -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMDebugInfoMSF -lLLVMSelectionDAG -lLLVMCodeGen -lLLVMBitWriter -lLLVMScalarOpts -lLLVMAggressiveInstCombine -lLLVMInstCombine -lLLVMTransformUtils -lLLVMTarget -lLLVMAnalysis -lLLVMProfileData -lLLVMXCoreDesc -lLLVMXCoreDisassembler -lLLVMMCDisassembler -lLLVMXCoreInfo -lLLVMXRay -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMBitReader -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMTextAPI -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -lxml2 -lz -liconv -lcharset -ldl -lrt -lm -lpthread && :
/usr/bin/ld: CMakeFiles/warp_compiler.dir/Compiler/Compile.cpp.o: in function `Warp::SyntaxTranslation::LLVM::initialize_target(llvm::Module&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, llvm::TargetOptions, llvm::Optional<llvm::Reloc::Model>)':
Compile.cpp:(.text+0x1534): undefined reference to `llvm::TargetRegistry::lookupTarget(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
/usr/bin/ld: CMakeFiles/warp_compiler.dir/Compiler/Main.cpp.o: in function `main':
Main.cpp:(.text+0xf46): undefined reference to `llvm::sys::getDefaultTargetTriple[abi:cxx11]()'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
1条答案
按热度按时间34gzjxbg1#
它使用的是旧的libstdcxx,我运行:
然后编辑我的conanfile.txt,使其只包含对
llvm-core/13.0.0
的引用,然后运行而现在它起作用了!