Hi, I'm on Linux and trying to link an application that makes use of LLVM's JIT execution engine statically. Setup: (1) LLVM libs are compiled as static libraries. (2) Called InitializeNativeTarget(). (3) Included llvm/ExecutionEngine/JIT.h. It works if I build and link regularly. However, if I add -static when linking, the execution engine fails to initialize. Does anyone know why? LLVM libs are already archives. Is that supported at all? Thanks & ciao, Mario
Yeah, this is a problem with the static constructor getting optimized out. Including "JIT.h" is supposed to fix that. Is it possible that the file where you are including "JIT.h" doesn't have any required code in it? -Andy -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Mario Schwalbe Sent: Tuesday, May 21, 2013 4:52 AM To: LLVM Devel Subject: [LLVMdev] Static linking of execution engine Hi, I'm on Linux and trying to link an application that makes use of LLVM's JIT execution engine statically. Setup: (1) LLVM libs are compiled as static libraries. (2) Called InitializeNativeTarget(). (3) Included llvm/ExecutionEngine/JIT.h. It works if I build and link regularly. However, if I add -static when linking, the execution engine fails to initialize. Does anyone know why? LLVM libs are already archives. Is that supported at all? Thanks & ciao, Mario _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Hi, Am 21.05.13 21:57, schrieb Kaylor, Andrew:> Yeah, this is a problem with the static constructor getting optimized out. Including "JIT.h" is supposed to fix that. > Is it possible that the file where you are including "JIT.h" doesn't have any required code in it?I'm including "JIT.h" directly in the main module, which also uses the engine. See the small test case attached. Even if I bypass the dummy object and call LLVMLinkInJIT() directly, it still gets optimized out... ciao, Mario -------------- next part -------------- /* * vim: set tabstop=4 shiftwidth=4 expandtab: */ #define DEBUG_TYPE "ExecutionEngineTest" #include <llvm/ExecutionEngine/Interpreter.h> #include <llvm/ExecutionEngine/JIT.h> #include <llvm/Support/TargetSelect.h> #include <llvm/LLVMContext.h> #include <llvm/Module.h> #include <cassert> using namespace llvm; int main(void) { InitializeNativeTarget(); #if 1 LLVMLinkInJIT(); #endif EngineBuilder engineBuilder(new Module("foo", getGlobalContext())); #if 0 engineBuilder.setEngineKind(EngineKind::Interpreter); #else engineBuilder.setEngineKind(EngineKind::JIT); #endif const OwningPtr<ExecutionEngine> executionEngine(engineBuilder.create()); assert(executionEngine && "Failed to create execution engine"); return 0; }
Reasonably Related Threads
- [LLVMdev] Static linking of execution engine
- [LLVMdev] Static linking of execution engine
- [LLVMdev] Trouble using the MCJIT: "Target does not support MC emission" error
- [LLVMdev] Trouble using the MCJIT: "Target does not support MC emission" error
- [LLVMdev] Trouble using the MCJIT: "Target does not support MC emission" error