[LLVMdev] Linking LLVM code with LLVM
Marc Ordinas i Llopis
lists at tragnarion.com
Thu Mar 17 03:18:34 PST 2005
Chris Lattner wrote:
> On Mon, 14 Mar 2005, Marc Ordinas i Llopis wrote:
>> Finally, I tried first generating the .o (bytecode) file, and then
>> linking got me the same result.
>> So, I'm really stuck here. Is there a way of linking LLVM-produced
>> code with LLVM? Has anyone tried it before?
> I guess I don't really understand what your goal is.
The goal is, simply, to be able to generate code (with the JIT) that
uses LLVM to generate more code. Most of today's VM runtimes include
ways of creating code at run time (.NET's reflection package, for example).
> Currently our support for transparently mixing native and llvm .o
> files (what you're trying to do) is pretty bad.
> If you really want to do this (and I'm still not sure at all why), you
> would want to compile one part of the program (either the part
> compiled with llvm-g++ or the part compiled with g++) to a native .so
> file, then compile the other part to a native application that links
> to it. You're not going to have much luck linking mixed
> bytecode/native .o files.
I got the JIT libraries compiled inside a native .so and tried to run
HowToUseJIT.bc, but it didn't work. Then, from the output I realized I
had been looking at the problem in the wrong way. It's not possible to
load the JIT from JITted code because there's already a JITter working.
Loading another one messes up the passes registry and the targets.
I think a way of doing this would be to make a version of lli that
somehow passes the execution engine handle into the JITted module. I'll
try this and tell you how it went.
Marc Ordinas i Llopis | Tragnarion Studios
PS: By the way, I found what I think are two glitches in the Makefiles.
First, LDFLAGS must be set before including Makefile.common to have any
effect, instead of after as the docs say. And second, USEDLIBS and LIBS
are ignored when building shared libraries.
More information about the llvm-dev