A non-JIT tutorial?

Although I have been using LLVM in non-JIT mode for a while, there are still a lot of holes in my knowledge. At lot of what I do know has been learned either through trial and error or through inspection of the LLVM source code. The downside of this approach is that while you might learn *one* way to get things working, it isn't necessarily the right or best way.

Looking at the traffic on this list, I think that I am not the only person in this position.

I think a tutorial for running and debugging LLVM programs in non-JIT mode would be very useful. The Kaleidoscope tutorial was immensely useful, but for folks like me who want to produce native binaries, it kind of tapers off right before the really interesting part. Of course, I recognize why this is: Any tutorial dealing with native binaries is going to have to deal with issues of different platforms and toolsets.

My suggestion/request is this: Start with a basic LLVM "hello world" sample written in IR, one that calls some c stdio functions. Next show how to run it in lli, both with and without -force-interpreter. Introduce a crash bug and show how to diagnose it. Then move on to generating native assembly, on both Linux (or OS X) and Windows, using whatever tool chain is most convenient (assume the reader is smart enough to generalize from those two sample points to other platforms.) Show how to call functions in foreign libraries. Again, introduce a problem and show how to diagnose it. Maybe add some sample debugging intrinsics and then show how to single-step in gdb.

I'm pretty certain that for me, at least, that I would learn a lot from such a tutorial, even after several months of testing my code using lli.

-- Talin

Talin wrote:

I think a tutorial for running and debugging LLVM programs in non-JIT mode would be very useful. The Kaleidoscope tutorial was immensely useful, but for folks like me who want to produce native binaries, it kind of tapers off right before the really interesting part. Of course, I recognize why this is: Any tutorial dealing with native binaries is going to have to deal with issues of different platforms and toolsets.

Yes please! I'm getting to the point in my project where I'm going to start wanting to generate native assembler instead of just the IR and I currently have no way of knowing where to start.

I'd also add that the 'problem' the OP mentions is actually the benefit in the tutorial; it's an opportunity to show off how versatile LLVM really is.

I think an easy place to start is from one of the chapters of the Kaleidoscope tutorial, where we have a fairly mature language implementation working to the IR stage. Just adding a chapter or two on how to go from here to something that someone with standard dev tools can get into a native binary would really round out the tutorial.

Dominic