Hello,
I am trying to run this basic C++ hello-world code in my iOS app that has LLVM libraries linked in (the app runs on the actual device - iPad Pro, iOS 13.4.1).
#include
int main (int argh, char *argv[]) {
std::cout << “Hello World!” << std::endl;
return 0;
}
So below is the break down of the steps that I do:
First I compile this code to an instance of llvm::Module by using the logic borrowed from the lli tool.
Once I have the Module instance I construct an instance of orc::LLLazyJIT (J), configure it (again closely following the logic in lli tool)
to which I then add the module like this:
// Add the main module.
ExitOnErr(J->addLazyIRModule(orc::ThreadSafeModule(std::move(MainModule), TSCtx)));
Finally the module is executed like this:
// Run main.
auto MainSym = ExitOnErr(J->lookup(“main”));
typedef int (*MainFnPtr)(int, char *[]);
auto Result = orc::runAsMain(
jitTargetAddressToFunction(MainSym.getAddress()), Args,
StringRef(“lli”));
The Xcode halts the execution when an assertion is triggered in llvm::jitlink::Symbol::constructNamedDef (the full call stack is below).
The line that triggers the assertion is this:
assert(Offset < Base.getSize() && “Symbol offset is outside block”);
because both Offset and Base.getSize() evaluate to 0).
The data referred to by the Base block is “Hello World!”.
I don’t understand why this assertion happens. Should the Base block size be > 0 ?
I am relatively new to LLVM, I did read the documentation on OCR Design and Implementation - but still can’t figure out what’s going on.
If there is any additional documentation I can read on running code using ORC/JIT APIs that would shed more light on the internals/implementation?
Any help would be greatly appreciated.
Thank you.