charles quarra
2012-Dec-17 05:31 UTC
[LLVMdev] Execution Engine issue with composite module
Hi, I'm having an issue with the below modules. I build module X, then module Y (which has a dependency on X). I've added an external declaration on module Y of the functions defined in X. i also link the except-handling module, but i think it is peripheral to the issue i like all the modules together in a single module called executableModule. I link them with the method: Linker::LinkModules(executableModule , moduleToLink, llvm::Linker::PreserveSource, &errorMsg); i call llvm::verifyModule(* executableModule, llvm::AbortProcessAction, &err); which doesn't seem to find anything wrong with the linked module. then i proceed to create the executionEngine: llvm::EngineBuilder eB(executableModule); eB.setEngineKind(llvm::EngineKind::JIT); llvmEngine = eB.create(); which seems to go well, but as soon as i run: llvm::Function* foo2 = moduleX->getFunction("foo2"); engine->getPointerToFunction(foo2); i get the error: LLVM ERROR: Program used external function 'foo' which could not be resolved! Any idea what is wrong? i thought linking those modules together in a single module would solve this problem. I've attached all the .ll files for the modules involved -------------- next part -------------- A non-text attachment was scrubbed... Name: except-handling.ll Type: application/octet-stream Size: 740 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121217/b7bc5599/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: executableModule.ll Type: application/octet-stream Size: 1547 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121217/b7bc5599/attachment-0001.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: X.ll Type: application/octet-stream Size: 355 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121217/b7bc5599/attachment-0002.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: Y.ll Type: application/octet-stream Size: 512 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121217/b7bc5599/attachment-0003.obj>
Clemens Hammacher
2012-Dec-17 10:23 UTC
[LLVMdev] Execution Engine issue with composite module
Hi Charles,> then i proceed to create the executionEngine: > > llvm::EngineBuilder eB(executableModule); > eB.setEngineKind(llvm::EngineKind::JIT); > llvmEngine = eB.create(); > > which seems to go well, but as soon as i run: > > llvm::Function* foo2 = moduleX->getFunction("foo2"); > engine->getPointerToFunction(foo2); > > i get the error: > > LLVM ERROR: Program used external function 'foo' which could not be resolved!Make sure that you get the Function* in the linked module, which is being executed by the ExecutionEngine (executableModule in your case). Cheers, Clemens
Reasonably Related Threads
- [LLVMdev] LLVM ERROR: Program used external function 'X.foo' which could not be resolved!
- Weak symbol/alias semantics
- [LLVMdev] Fwd: error while linking modules with exception handling demo code
- [LLVMdev] BlockAddress instruction is copied instead of cloned during module link?
- JIT, LTO and @llvm.global_ctors: Looking for advise