<div dir="ltr">Hi All,<div><br></div><div>I'm going to be making some API breaking changes to the ORC APIs, and to the RuntimeDyld class (which underlies MCJIT). The changes may affect MCJIT clients but are unlikely to. Where they do the fixes are likely to be trivial. ORC clients will be affected, but the fixes should also be straightforward.</div><div><br></div><div>I have three upcoming changes in mind:</div><div><br></div><div>1) RuntimeDyld (the linker underlying MCJIT and ORC) will now search for symbols using the SymbolResolver's findSymbolInLogicalDylib first, before falling back to the findSymbol method if findSymbolInLogicalDylib returns a null result.</div><div><br></div><div>This is a step towards making RuntimeDyld behave more like a static linker: we prefer to link against symbols defined in the same "logical dylib" as the module being JIT'd, before linking against external symbols.</div><div><br></div><div>For clients that have not implemented findSymbolInLogicalDylib (I suspect this covers most clients) this change will have no effect: the default version of findSymbolInLogicalDylib will be called and will return null, and RuntimeDyld will fall back to calling findSymbol as it did before.</div><div><br></div><div>For clients that have implemented findSymbolInLogicalDylib: Beware that any symbol found via this call will now shadow symbols that might have been found via findSymbol. It is unlikely that anyone is relying on non-shadowing so I don't expect any trouble here, but if you do see any changes in symbol resolution after this change (which I expect to land today) this is something to have in mind.</div><div><br></div><div>2) MemoryManager deregisterEHFrames will be removed.</div><div><br></div><div>Memory managers should own their registered EH frames and deregister them on destruction. This will bring EH frame ownership in line with memory ownership: memory managers are already responsible for freeing the memory that they've allocated when they are destructed.</div><div> <br></div><div>To transition, clients should track the frames registered by their class, then deregister them in the destructor. For in-tree memory managers (and RuntimeDyld itself) this bug is being tracked by <a href="https://llvm.org/PR23991">https://llvm.org/PR23991</a> .</div><div><br></div><div>3) Some operations in the ORC APIs, RuntimeDyld, SymbolResolver and MemoryManager will be modified to return Error/Expected.</div><div><br></div><div>MCJIT and ORC both support remote execution of JIT'd code via RPC, but there is currently no way to cleanly bail out and report failure in the case of an RPC error. Adding error returns provides the mechanism we need.</div><div><br></div><div>When the interfaces are changed to add error returns clients will see compile-time errors for any custom ORC-based stacks, derived symbol resolvers, or memory managers. Most clients will just be able to update their offending return types and leave their function body as-is (for Expected<T> returns) or return llvm::Error::success() (for Error returns). Clients who are actually using the remote-JITing features will now be able to return any errors that they had previously been dropping or bailing out on. This change is being tracked by <a href="https://llvm.org/PR22612">https://llvm.org/PR22612</a> .</div><div><br></div><div>I've held off making these changes for a while, because I know there are a lot of out-of-tree JIT clients and I want to avoid breaking your code. I think this churn is worth the pain though - the resulting APIs will have less historical baggage, be more error-proof, and enable some new features.</div><div><br></div><div>Please let me know if you have any questions or run into any trouble as these changes land - I'll be happy to help out.</div><div><br></div><div>Cheers,</div><div>Lang.</div></div>