PacktPublishing / Learn-LLVM-12

Learn LLVM 12, published by Packt
MIT License
474 stars 103 forks source link

Fix Chapter 10 JIT Example #14

Open heksterb opened 2 years ago

heksterb commented 2 years ago

The CMakeLists.txt appears to be missing libraries needed to build the example:

/usr/bin/ld: CMakeFiles/JIT.dir/JIT.cpp.o: undefined reference to symbol '_ZN4llvm20SectionMemoryManagerC1EPNS0_12MemoryMapperE'
/usr/bin/ld: /usr/local/lib/libLLVMExecutionEngine.so.12: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/JIT.dir/build.make:106: JIT] Error 1
make[1]: *** [CMakeFiles/Makefile2:164: CMakeFiles/JIT.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Also, the sample main.llIR will raise an error when run on a non AMD64 architecture:

JIT: /home/heksterb/llvm-project/llvm/lib/CodeGen/MachineFunction.cpp:201: void llvm::MachineFunction::init(): Assertion `Target.isCompatibleDataLayout(getDataLayout()) && "Can't create a MachineFunction using a Module with a " "Target-incompatible DataLayout attached\n"' failed.

I've included one that works for ARM aarch64 to illustrate that the file is architecture-dependent.