ORC - which example code?

Trying to put together a simple test JIT compiler, using ORC which as I understand it will be the supported API going forward, I noticed that in the first chapter of the updated Kaleidoscope tutorial, there is sample code that starts like this:

ExecutionSession ES;
RTDyldObjectLinkingLayer ObjectLayer;
IRCompileLayer CompileLayer;

DataLayout DL;
MangleAndInterner Mangle;
ThreadSafeContext Ctx;

But in https://llvm.org/devmtg/2016-11/Slides/Hames-ORC.pdf there is sample code that looks like this:

ObjectLinkingLayer LinkLayer;
SimpleCompiler Compiler(TargetMachine());
IRCompileLayer<…> CompileLayer(LinkLayer, Compiler);

Related but significantly different.

Which version is now considered correct/preferred?

Hi Russell
As far as I know, the second is preferred. You can also look at the LLJIT && LLLazyJIT stack in the trunk which is off the shelf utility.

Thanks

It turns out that ObjectLinkingLayer doesn’t exist; that identifier occurs in the source tree only in comments, never as an identifier.

Does that mean the second version of the API has been deleted and the first is now correct?

Hey Russel

RTDyldObjectLinkingLayer is the regular one, which makes use of RuntimeDyld under the hood. This should be the default and work with both, OrcV1 and OrcV2.

ObjectLinkingLayer is the layer that Lang plans to use for JITLink. This was added very recently [1] with the ultimate goal to get rid of RuntimeDyld, which allows relaxed constraints on the used CodeModel, better supports concurrency and overcomes hacks like [2]. It’s definitely not something you want to use in production at this point. It lacks a number of features compared to RuntimeDlyld, i.e. backends for all object formats except Mach-O and compatibility with JITEventListeners.

If you look for RTDyldObjectLinkingLayer examples in-tree, see how LLJIT does it [3] and how lli uses LLLazyJIT [4].
Out-of-tree you can have a look at my example project if you like: it shows how to build on LLJIT [5] and how to break free from it [6]. This is much more focused than the in-tree code.

Hope it helps.
Best, Stefan