[llvm-dev] Compile issues with LLVM ORC JIT

Ingmar Kühl via llvm-dev llvm-dev at lists.llvm.org
Sun Aug 6 09:35:41 PDT 2017


I tree to compile the LLVM ORC JIT examples. But I'm stuck in some 
problems I can't solve my own.

First at all I compile with C++14 enabled with latest stable LLVM and 
clang, this means 4.0.1. I get the following error. Do I missed some 
specific compile option?

Compilation looks like this here.

|CompilingcontribJIT.cpp 
PWD:/home/ikuehl/projects-llvm/TurboLisp/domainEngineer 
Sourcefile:contribJIT Sourcefile type:cpp source sub-folder:src/contrib 
Compiler:/usr/local/bin/clang++COMPILE_FLAG option:-v -g0 -fPIC 
-fno-use-cxa-atexit -emit-llvm -I/usr/local/include -I/opt/BOOST/include 
-std=c++14-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS 
LLVM_CONFIG_COMPILE option:-I/usr/local/include -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
option:-emit-llvm sub-path:contrib lto:-flto=thin -O3 iftest 
"contrib"="contrib/parser";then cd 
bin/x86_64/contrib;`/usr/local/bin/clang++-emit-llvm -c -v -g0 -fPIC 
-fno-use-cxa-atexit -emit-llvm -I/usr/local/include -I/opt/BOOST/include 
-std=c++14-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS 
../../../src/contrib/'contribJIT'.'cpp'-o 'contribJIT'.o 
`/usr/local/bin/llvm-config --cppflags``;cd ..;elsecd 
bin/x86_64/contrib;`/usr/local/bin/clang++-emit-llvm -c -v -g0 -fPIC 
-fno-use-cxa-atexit -emit-llvm -I/usr/local/include -I/opt/BOOST/include 
-std=c++14-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS 
../../../src/contrib/'contribJIT'.'cpp'-o 'contribJIT'.o 
`/usr/local/bin/llvm-config --cppflags``;cd ..;fi clang version 
4.0.1(tags/RELEASE_401/final)Target:x86_64-unknown-linux-gnu 
Threadmodel:posix InstalledDir:/usr/local/bin Foundcandidate GCC 
installation:/usr/lib/gcc/x86_64-linux-gnu/6Foundcandidate GCC 
installation:/usr/lib/gcc/x86_64-linux-gnu/6.3.0SelectedGCC 
installation:/usr/lib/gcc/x86_64-linux-gnu/6.3.0Candidatemultilib:.;@m64Selectedmultilib:.;@m64"/usr/local/bin/clang-4.0"-cc1 
-triple x86_64-unknown-linux-gnu -emit-llvm-bc -emit-llvm-uselists 
-disable-free -main-file-name contribJIT.cpp -mrelocation-model pic 
-pic-level 2-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 
-coverage-notes-file 
/home/ikuehl/projects-llvm/TurboLisp/domainEngineer/bin/x86_64/contrib/contribJIT.gcno 
-resource-dir /usr/local/bin/../lib/clang/4.0.1-I /usr/local/include -I 
/opt/BOOST/include -D __STDC_CONSTANT_MACROS -D __STDC_LIMIT_MACROS 
-internal-isystem 
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0-internal-isystem 
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0-internal-isystem 
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0-internal-isystem 
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward 
-internal-isystem /usr/local/include -internal-isystem 
/usr/local/bin/../lib/clang/4.0.1/include -internal-externc-isystem 
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include 
-internal-externc-isystem /usr/include -std=c++14-fdeprecated-macro 
-fdebug-compilation-dir 
/home/ikuehl/projects-llvm/TurboLisp/domainEngineer/bin/x86_64/contrib 
-ferror-limit 19-fmessage-length 237-fno-use-cxa-atexit 
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions 
-fdiagnostics-show-option -fcolor-diagnostics -o contribJIT.o -x 
c++../../../src/contrib/contribJIT.cpp clang -cc1 version 4.0.1based 
upon LLVM 4.0.1defaulttarget x86_64-unknown-linux-gnu ignoring 
nonexistent directory "/include"ignoring duplicate directory 
"/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0"ignoring 
duplicate directory "/usr/local/include"as it is a non-system directory 
that duplicates a system directory #include"..."search starts 
here:#include<...>search starts here:/opt/BOOST/include 
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward 
/usr/local/include /usr/local/bin/../lib/clang/4.0.1/include 
/usr/include/x86_64-linux-gnu /usr/include Endof search list.|

The error I get is this:

    error: unknown type name 'RTDyldObjectLinkingLayer'; did you mean
    'RTDyldObjectLinkingLayerBase'?

Moreover, I get more errors. This tells me something is wrong with the 
templating.

    error: too many template arguments for class template
    'IRCompileLayer' IRCompileLayer CompileLayer;

Another error with regards to RTDyldObjectLinkingLayer:

    error: too many template arguments for class template
    'IRCompileLayer' IRCompileLayer CompileLayer;

|#define_CONTRIB_JIT_ 
1#include"llvm/ADT/STLExtras.h"#include"llvm/ExecutionEngine/ExecutionEngine.h"#include"llvm/ExecutionEngine/JITSymbol.h"#include"llvm/ExecutionEngine/RTDyldMemoryManager.h"#include"llvm/ExecutionEngine/SectionMemoryManager.h"#include"llvm/ExecutionEngine/Orc/CompileUtils.h"#include"llvm/ExecutionEngine/Orc/IRCompileLayer.h"#include"llvm/ExecutionEngine/Orc/LambdaResolver.h"#include"llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"#include"llvm/IR/DataLayout.h"#include"llvm/IR/Mangler.h"#include"llvm/Support/DynamicLibrary.h"#include"llvm/Support/raw_ostream.h"#include"llvm/Target/TargetMachine.h"#include<algorithm>#include<memory>#include<string>#include<vector>usingnamespacellvm;usingnamespacellvm::orc;namespacetl 
{namespacecontrib 
{classGenericJIT{private:std::unique_ptr<TargetMachine>TM;constDataLayoutDL;RTDyldObjectLinkingLayerObjectLayer;IRCompileLayer<decltype(ObjectLayer),SimpleCompiler>CompileLayer;public:usingModuleHandle=decltype(CompileLayer)::ModuleSetHandleT;GenericJIT():TM(EngineBuilder().selectTarget()),DL(TM->createDataLayout()),ObjectLayer([](){returnstd::make_shared<SectionMemoryManager>();}),CompileLayer(ObjectLayer){llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);}TargetMachine&getTargetMachine(){return*TM;}ModuleHandleaddModule(std::unique_ptr<Module>M){// 
Build our symbol resolver:// Lambda 1: Look back into the JIT itself to 
find symbols that are part of// the same "logical dylib".// Lambda 2: 
Search for external symbols in the host 
process.autoResolver=createLambdaResolver([&](conststd::string 
&Name){if(autoSym=CompileLayer.findSymbol(Name,false))returnSym;returnJITSymbol(nullptr);},[](conststd::string 
&Name){if(autoSymAddr=RTDyldMemoryManager::getSymbolAddressInProcess(Name))returnJITSymbol(SymAddr,JITSymbolFlags::Exported);returnJITSymbol(nullptr);});// 
Add the set to the JIT with the resolver we created above and a newly// 
created 
SectionMemoryManager.returncantFail(CompileLayer.addModule(std::move(M),std::move(Resolver)));}JITSymbolfindSymbol(conststd::string 
Name){std::string MangledName;raw_string_ostream 
MangledNameStream(MangledName);Mangler::getNameWithPrefix(MangledNameStream,Name,DL);returnCompileLayer.findSymbol(MangledNameStream.str(),true);}voidremoveModule(ModuleHandleH){cantFail(CompileLayer.removeModule(H));}};}}|

The code is 1-to-1 copied from LLVM web site,LLVM ORC JIT Example 
<https://llvm.org/docs/tutorial/BuildingAJIT3.html>.

Could anybody tell me what I missed in my code, or in compile options?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170806/c8cd010d/attachment-0001.html>


More information about the llvm-dev mailing list