Stanislav Pankevich via llvm-dev
2018-May-16 19:06 UTC
[llvm-dev] LLVM JIT 3.9 vs 6.0: How to emitAndFinalize multiple modules correctly?
Hi all, I am having hard time figuring out how I should use the API for JIT in LLVM 6. In LLVM 3.9 I am used to adding all objects at once and emitAndFinalizing them all: handle = objectLayer.addObjectSet(objectFiles, memoryManager, resolver); objectLayer.emitAndFinalize(handle); In LLVM 6.0 the objects are added one by one: auto handle = objectLayer.addObject(objectFile, resolver).get(); objectLayer.emitAndFinalize(handle); The problem is that emitAndFinalize in this case works for one module and JIT exits on "LLVM ERROR: Program used external function 'XXXX' which could not be resolved!" errors because it seems to not see the other modules loaded with addObject. What am I missing? Thanks, Stanislav
Stefan Gränitz via llvm-dev
2018-May-16 19:46 UTC
[llvm-dev] LLVM JIT 3.9 vs 6.0: How to emitAndFinalize multiple modules correctly?
Hi Stan, the change happend with 5.0 [1]. There's a few options: (1) Submit all modules and then explicitly finalize one after the other. (2) Skip the explicit finalization, it should happen lazily for the respective modules, when querying a function name. (3) Last but not least, you could also merge all your modules into one using Linker::link() [2] and submit this one. (This should be the closest to pre-5.0) You probably want to use a single resolver for all of them. Simply forward symbol queries to your top ORC layer, and (again) it should on-demand emit & finalize the respective module if it hasn't happened already. E.g.: https://github.com/weliveindetail/JitFromScratch/blob/jit-basics/SimpleOrcJit.h#L31 Hope it helps! Best, Stefan [1] https://weliveindetail.github.io/blog/post/2017/08/23/llvm50-release-orc-api-changes.html#orclayerconceptaddmodule [2] http://llvm.org/doxygen/classllvm_1_1Linker.html#a72e11e8404db974fa400748b888ea49d Am 16.05.18 um 21:06 schrieb Stanislav Pankevich:> Hi all, > > I am having hard time figuring out how I should use the API for JIT in LLVM 6. > > In LLVM 3.9 I am used to adding all objects at once and > emitAndFinalizing them all: > > handle = objectLayer.addObjectSet(objectFiles, memoryManager, resolver); > objectLayer.emitAndFinalize(handle); > > In LLVM 6.0 the objects are added one by one: > > auto handle = objectLayer.addObject(objectFile, resolver).get(); > objectLayer.emitAndFinalize(handle); > > The problem is that emitAndFinalize in this case works for one module > and JIT exits on > "LLVM ERROR: Program used external function 'XXXX' which could not be resolved!" > errors because it seems to not see the other modules loaded with addObject. > > What am I missing? > > Thanks, > > Stanislav-- https://weliveindetail.github.io/blog/ https://cryptup.org/pub/stefan.graenitz at gmail.com
Possibly Parallel Threads
- Invalid Signature of orc::RTDyldObjectLinkingLayer::NotifyLoadedFtor
- [cfe-dev] JIT doens't resolve address - Resolve obj-Addresses?
- "corrupted size vs. prev_size" when calling ExecutionSession::lookup()
- OrcJIT + CUDA Prototype for Cling
- ORC JIT api, object files and stackmaps