I wrote a little OS X app to assemble some LLVM (human-readable) code and run it. Unfortunately, my ExecutionEngine won't create. Just comes back NULL. This is the code that builds it: http://pastebin.com/8cexgPj7 This is the code it seems to successfully assemble, but it can't build the ExecutionEngine. You can see I tried several different ways of building it. http://pastebin.com/tYq4kWX3 The module seems to get created properly (you can see the source and the result of mod->dump()). Is there a dylib that I need to include that has some init code that's otherwise not invoked? How can I tell why my ExecutionEngine didn't create? Is there an error code somewhere? I based my code off the HowTouseJIT.cpp example, llvm-as.cpp, and lli.cpp. I must've overlooked something, but I'm not sure what. Any ideas? Thanks! -- Rick
Hi Rick, I had the same problem last week I understand that I didn't initialized target. Cheers, Manuele Il 08/01/2013 16:08, Rick Mann ha scritto:> I wrote a little OS X app to assemble some LLVM (human-readable) code and run it. Unfortunately, my ExecutionEngine won't create. Just comes back NULL. > > This is the code that builds it: > > http://pastebin.com/8cexgPj7 > > This is the code it seems to successfully assemble, but it can't build the ExecutionEngine. You can see I tried several different ways of building it. > > http://pastebin.com/tYq4kWX3 > > The module seems to get created properly (you can see the source and the result of mod->dump()). > > Is there a dylib that I need to include that has some init code that's otherwise not invoked? How can I tell why my ExecutionEngine didn't create? Is there an error code somewhere? > > I based my code off the HowTouseJIT.cpp example, llvm-as.cpp, and lli.cpp. I must've overlooked something, but I'm not sure what. > > > Any ideas? Thanks! >
Sorry I forgot to add code that I use to run code: /* Executes the AST by running the main function */ GenericValue CodeGenContext::runCode() { std::cout << "Running code...\n"; ExecutionEngine *ee = EngineBuilder(module).create(); vector<GenericValue> noargs; GenericValue v = ee->runFunction(mainFunction, noargs); std::cout << "Code was run.\n"; return v; } Il 08/01/2013 16:38, Manuele Conti ha scritto:> Hi Rick, > I had the same problem last week I understand that I didn't > initialized target. > > Cheers, > Manuele > > Il 08/01/2013 16:08, Rick Mann ha scritto: >> I wrote a little OS X app to assemble some LLVM (human-readable) code >> and run it. Unfortunately, my ExecutionEngine won't create. Just >> comes back NULL. >> >> This is the code that builds it: >> >> http://pastebin.com/8cexgPj7 >> >> This is the code it seems to successfully assemble, but it can't >> build the ExecutionEngine. You can see I tried several different ways >> of building it. >> >> http://pastebin.com/tYq4kWX3 >> >> The module seems to get created properly (you can see the source and >> the result of mod->dump()). >> >> Is there a dylib that I need to include that has some init code >> that's otherwise not invoked? How can I tell why my ExecutionEngine >> didn't create? Is there an error code somewhere? >> >> I based my code off the HowTouseJIT.cpp example, llvm-as.cpp, and >> lli.cpp. I must've overlooked something, but I'm not sure what. >> >> >> Any ideas? Thanks! >> > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130108/4ecd4cd7/attachment.html>
Hi Rick, You need to include 'llvm/ExecutionEngine/JIT.h' (or 'llvm/ExecutionEngine/JIT.h' if you want that engine) from your main file. Including that file forces the JIT static constructor to be linked into your executable. Without it, the JIT static constructor gets optimized out and you get the result you're seeing. -Andy -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Rick Mann Sent: Tuesday, January 08, 2013 7:09 AM To: llvmdev at cs.uiuc.edu Subject: [LLVMdev] ExecutionEngine always comes back NULL I wrote a little OS X app to assemble some LLVM (human-readable) code and run it. Unfortunately, my ExecutionEngine won't create. Just comes back NULL. This is the code that builds it: http://pastebin.com/8cexgPj7 This is the code it seems to successfully assemble, but it can't build the ExecutionEngine. You can see I tried several different ways of building it. http://pastebin.com/tYq4kWX3 The module seems to get created properly (you can see the source and the result of mod->dump()). Is there a dylib that I need to include that has some init code that's otherwise not invoked? How can I tell why my ExecutionEngine didn't create? Is there an error code somewhere? I based my code off the HowTouseJIT.cpp example, llvm-as.cpp, and lli.cpp. I must've overlooked something, but I'm not sure what. Any ideas? Thanks! -- Rick _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Jan 8, 2013, at 13:55 , "Kaylor, Andrew" <andrew.kaylor at intel.com> wrote:> You need to include 'llvm/ExecutionEngine/JIT.h' (or 'llvm/ExecutionEngine/JIT.h' if you want that engine) from your main file. Including that file forces the JIT static constructor to be linked into your executable. Without it, the JIT static constructor gets optimized out and you get the result you're seeing.Wow, how obscure! Thank you; I never would've figured that out. Why is it done that way? That seems…quite horrible, actually. Why not just instantiate the JIT on demand as part of instantiating the Engine? Thanks again. It works now. Thank you. Thank you. -- Rick