[llvm-commits] [patch] fix linking of llvm-ld and lli with cmake
Xerxes RĂ„nby
xerxes at zafena.se
Thu Jun 25 04:12:57 PDT 2009
The problem:
Linking CXX executable ../../bin/llvm-ld
../../lib/libLLVMTransformUtils.a(LCSSA.cpp.o): In function
`llvm::PredIteratorCache::~PredIteratorCache()':
LCSSA.cpp:(.text._ZN4llvm17PredIteratorCacheD1Ev[llvm::PredIteratorCache::~PredIteratorCache()]+0x11):
undefined reference to `llvm::BumpPtrAllocator::~BumpPtrAllocator()'
...
../../lib/libLLVMAnalysis.a(DebugInfo.cpp.o): In function
`llvm::DIDescriptor::dump() const':
DebugInfo.cpp:(.text+0x1e7e): undefined reference to
`llvm::dwarf::TagString(unsigned int)'
...
Linking CXX executable ../../bin/lli
../../lib/libLLVMCodeGen.a(LLVMTargetMachine.cpp.o): In function
`llvm::LLVMTargetMachine::addCommonCodeGenPasses(llvm::PassManagerBase&,
llvm::CodeGenOpt::Level)':
LLVMTargetMachine.cpp:(.text+0x914): undefined reference to
`llvm::createPrintFunctionPass(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&,
llvm::raw_ostream*, bool)'
...
../../lib/libLLVMScalarOpts.a(CodeGenPrepare.cpp.o): In function
`llvm::operator<<(llvm::BaseStream<std::basic_ostream<char,
std::char_traits<char> > >&, llvm::ExtAddrMode const&)':
CodeGenPrepare.cpp:(.text+0x8a4): undefined reference to
`llvm::ExtAddrMode::print(llvm::BaseStream<std::basic_ostream<char,
std::char_traits<char> > >&) const'
This was quite odd since both libLLVMSupport.a and
libLLVMTransformUtils.a got passed to the linker:
nm -A lib/*.a | c++filt | grep llvm::BumpPtrAllocator::~BumpPtrAllocator
..
lib/libLLVMSupport.a:Allocator.cpp.o:000004f6 T
llvm::BumpPtrAllocator::~BumpPtrAllocator()
lib/libLLVMSupport.a:Allocator.cpp.o:00000508 T
llvm::BumpPtrAllocator::~BumpPtrAllocator()
lib/libLLVMTransformUtils.a:LCSSA.cpp.o: U
llvm::BumpPtrAllocator::~BumpPtrAllocator()
by analysing the generated library .a archives it was clear the methods
existed yet the linker tried to combine the librarys in the wrong order.
remember that linkers never look back to see if a new undefined symbol
existed in a file it had allready processed.
thus if libLLVMSupport.a are passed to the linker before
libLLVMTransformUtils.a then the linker will fail saying
libLLVMTransformUtils.a have missing symbols.
The solution:
add target_link_libraries dependencies to the libraries so that cmake
can figure out in what order the librarys should be passed to the linker.
This patch includes only whats needed to compleatly build llvm using cmake.
Cheers
Xerxes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmake_dependencies.patch
Type: text/x-patch
Size: 1930 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090625/477a0da1/attachment.bin>
More information about the llvm-commits
mailing list