Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLVM Kaleidoscope tutorial JIT compilation problem

Tags:

c++

linux

llvm

I have some problems following the Kaleidoscope JIT chapter tutorial.

I compile with: (just like the tutorial page advises)

clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core mcjit native` -rdynamic -O3 -o toy
/tmp/toy-ce525d.o: In function `llvm::orc::LegacyIRCompileLayer<llvm::orc::LegacyRTDyldObjectLinkingLayer, llvm::orc::SimpleCompiler>::addModule(unsigned long, std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >)':
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h:93: undefined reference to `llvm::orc::SimpleCompiler::operator()(llvm::Module&)'
/tmp/toy-ce525d.o: In function `llvm::orc::LegacyRTDyldObjectLinkingLayer::ConcreteLinkedObject<std::shared_ptr<llvm::RuntimeDyld::MemoryManager> >::finalize()':
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h:237: undefined reference to `llvm::orc::JITSymbolResolverAdapter::JITSymbolResolverAdapter(llvm::orc::ExecutionSession&, llvm::orc::SymbolResolver&, llvm::orc::MaterializationResponsibility*)'
/tmp/toy-ce525d.o: In function `llvm::orc::JITSymbolResolverAdapter::~JITSymbolResolverAdapter()':
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:93: undefined reference to `vtable for llvm::orc::JITSymbolResolverAdapter'
/tmp/toy-ce525d.o: In function `KaleidoscopeJIT':
/home/user/Desktop/llvm/kaleidoscope/other/././KaleidoscopeJIT.h:45: undefined reference to `llvm::orc::ExecutionSession::ExecutionSession(std::shared_ptr<llvm::orc::SymbolStringPool>)'
/tmp/toy-ce525d.o: In function `llvm::DenseSet<llvm::orc::SymbolStringPtr, llvm::DenseMapInfo<llvm::DenseSet> > llvm::orc::lookupWithLegacyFn<llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1}>(llvm::orc::ExecutionSession&, llvm::orc::AsynchronousSymbolQuery&, llvm::DenseMapInfo<llvm::DenseSet> const&, llvm::orc::KaleidoscopeJIT::KaleidoscopeJIT()::{lambda(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)#1})':
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:159: undefined reference to `llvm::orc::ExecutionSession::legacyFailQuery(llvm::orc::AsynchronousSymbolQuery&, llvm::Error)'
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:151: undefined reference to `llvm::orc::AsynchronousSymbolQuery::notifySymbolMetRequiredState(llvm::orc::SymbolStringPtr const&, llvm::JITEvaluatedSymbol)'
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:155: undefined reference to `llvm::orc::ExecutionSession::legacyFailQuery(llvm::orc::AsynchronousSymbolQuery&, llvm::Error)'
/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/Legacy.h:166: undefined reference to `llvm::orc::AsynchronousSymbolQuery::handleComplete()'
/tmp/toy-ce525d.o:(.rodata._ZTVN4llvm3orc22LegacyLookupFnResolverIZNS0_15KaleidoscopeJITC1EvEUlRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE_EE[_ZTVN4llvm3orc22LegacyLookupFnResolverIZNS0_15KaleidoscopeJITC1EvEUlRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE_EE]+0x30): undefined reference to `llvm::orc::SymbolResolver::anchor()'

LLVM project in version 10, clang++ in version 6.

$ uname -srmpo
Linux 4.15.0-72-generic x86_64 x86_64 GNU/Linux
$ clang++ --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ llvm-config --version
10.0.0git
like image 430
Bartosz Białas Avatar asked Jan 02 '20 10:01

Bartosz Białas


People also ask

Why does Kaleidoscope remove functions from the JIT?

Since Kaleidoscope is generally a dynamic language it is possible and reasonable for the user to re-define a function (to fix an error, or provide a completely different implementation all together). Therefore, any named functions are removed from the JIT, if they existed, before adding in the new definition.

What is kaleidoscopejit?

For Kaleidoscope, two such functions are defined directly in KaleidoscopeJIT (putchard and printd), which is consistent with the same functions used in the official LLVM C++ tutorial. Thus, allowing sharing of samples between the two.

What is putchard in Kaleidoscope JIT?

For Kaleidoscope, two such functions are defined directly in KaleidoscopeJIT (putchard and printd), which is consistent with the same functions used in the official LLVM C++ tutorial. Thus, allowing sharing of samples between the two. These functions are used to provide rudimentary console output support.


1 Answers

PradeepKumar fixed the issue in the comment.

This command compiles the code:

clang++ -g toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core mcjit native orcjit` -rdynamic -O3 -o toy
like image 167
Bartosz Białas Avatar answered Nov 02 '22 10:11

Bartosz Białas