[llvm-dev] Compile issues with LLVM ORC JIT

Alex Denisov via llvm-dev llvm-dev at lists.llvm.org
Fri Aug 11 01:10:17 PDT 2017


The issue is that Ingmar is using LLVM 4.1, while taking example from trunk’s documentation.
Here is my comment on the same question at SO: https://stackoverflow.com/questions/45520302/compile-issues-with-llvm-orc-jit#comment78051155_45520302
So probably nothing to look at, Lang.

> On 11. Aug 2017, at 03:20, Lang Hames via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi Ingmar,
> 
> The example code (in llvm/examples/Kaleidoscope/BuildingAJIT/) should compile, but the tutorial text may be out of date after recent changes to the ORC APIs. I'm looking in to this now.
> 
> Cheers,
> Lang.
> 
> On Tue, Aug 8, 2017 at 12:40 AM, Stefan Gränitz via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> Hi Ingmar
> 
> What version of LLVM are you building against?
> Did you try building the original example from the LLVM sources in llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3?
> 
>> The code is 1-to-1 copied from LLVM web site, LLVM ORC JIT Example.
> There's quite a few differences actually (namespaces, class name, include guard).
> 
>> First at all I compile with C++14 enabled
> Did you configure your LLVM build with LLVM_ENABLE_CXX1Y=ON? It's probably not the issue here, but sticking to one set of compile options for all parts of a project saves headache.
> 
>> 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;
> That's two times the same ;)
> 
> If you are not sure about your toolchain configuration, did you consider using CMake?
> 
> Cheers
> Stefan
> 
> Am 06.08.17 um 18:35 schrieb Ingmar Kühl via llvm-dev:
>> 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.
>> 
>> Compiling contribJIT.
>> cpp
>> PWD
>> :  /home/ikuehl/projects-llvm/TurboLisp/domainEngineer  Source file: contribJIT  Source file 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
>> 
>> 
>> if test "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 ..; else 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 ..;
>>  fi
>> clang version
>> 4.0.1 (tags/RELEASE_401/final)
>> Target: x86_64-unknown-linux-
>> gnu
>> 
>> Thread model:
>>  posix
>> 
>> InstalledDir: /usr/local/
>> bin
>> 
>> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
>> Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.3.0
>> Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.3.0
>> Candidate multilib: .;@m64
>> Selected multilib: .;@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.1 based upon LLVM 4.0.1 default target 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
>> 
>> End of 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>
>> 
>> 
>> 
>> using namespace llvm;
>> using namespace llvm::orc;
>> 
>> 
>> 
>> namespace tl {
>> 
>> 
>> namespace contrib {
>> 
>> 
>> 
>> class GenericJIT {
>> 
>> 
>> 
>> private:
>> 
>>       std
>> ::unique_ptr<TargetMachine> TM;
>> 
>> 
>> const DataLayout DL;
>> 
>> 
>> RTDyldObjectLinkingLayer ObjectLayer;
>> 
>> 
>> IRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
>> 
>> 
>> 
>> public:
>> 
>> 
>> using ModuleHandle = decltype(CompileLayer)::ModuleSetHandleT;
>> 
>> 
>> 
>> GenericJIT()
>> 
>> 
>> : TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
>> 
>> 
>> ObjectLayer([]() { return std::make_shared<SectionMemoryManager>(); }),
>> 
>> 
>> CompileLayer(ObjectLayer) {
>> 
>>     llvm
>> ::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
>> 
>> 
>> }
>> 
>> 
>> 
>> TargetMachine &getTargetMachine() { return *TM; }
>> 
>> 
>> 
>> ModuleHandle addModule(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.
>> 
>> 
>> auto Resolver = createLambdaResolver(
>> 
>> 
>> [&](const std::string &Name) {
>> 
>> 
>> if (auto Sym = CompileLayer.findSymbol(Name, false))
>> 
>> 
>> return Sym;
>> 
>> 
>> return JITSymbol(nullptr);
>> 
>> 
>> },
>> 
>> 
>> [](const std::string &Name) {
>> 
>> 
>> if (auto SymAddr =
>> 
>> 
>> RTDyldMemoryManager::getSymbolAddressInProcess(Name))
>> 
>> 
>> return JITSymbol(SymAddr, JITSymbolFlags::Exported);
>> 
>> 
>> return JITSymbol(nullptr);
>> 
>> 
>> });
>> 
>> 
>> 
>> // Add the set to the JIT with the resolver we created above and a newly
>> 
>> 
>> // created SectionMemoryManager.
>> 
>> 
>> return cantFail(CompileLayer.addModule(std::move(M),
>> 
>>                            std
>> ::move(Resolver)));
>> 
>> 
>> }
>> 
>> 
>> 
>> JITSymbol findSymbol(const std::string Name) {
>> 
>>     std
>> ::string MangledName;
>> 
>>     raw_string_ostream
>> MangledNameStream(MangledName);
>> 
>> 
>> Mangler::getNameWithPrefix(MangledNameStream, Name, DL);
>> 
>> 
>> return CompileLayer.findSymbol(MangledNameStream.str(), true);
>> 
>> 
>> }
>> 
>> 
>> 
>> void removeModule(ModuleHandle H) {
>> 
>>     cantFail
>> (CompileLayer.removeModule(H));
>> 
>> 
>> }
>> 
>> 
>> };
>> 
>> 
>> 
>> }
>> }
>> The code is 1-to-1 copied from LLVM web site, LLVM ORC JIT Example.
>> 
>> Could anybody tell me what I missed in my code, or in compile options?
>> 
>> 
>> 
>> ______________________________
>> _________________
>> LLVM Developers mailing list
>> 
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> 
> --
> 
> https://weliveindetail.github.io/blog/
> https://cryptup.org/pub/stefan.graenitz@gmail.com
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> 
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170811/67aaa7a0/attachment.sig>


More information about the llvm-dev mailing list