[LLVMdev] Output to a DLL

Óscar Fuentes ofv at wanadoo.es
Thu Jun 11 08:39:00 PDT 2009


"Nicolas Capens" <nicolas at capens.net> writes:

Hello Nicolas.

> I'd like to be able to write JIT-compiled code to a Windows DLL. I have no
> idea where to start though. Does LLVM already offer some support for
> this?

Nope. Don't hold your breadth waiting for it. It is far from trivial to
do.

I don't know your requirements, but mine is to avoid compilation every
time the hosting application starts.

I was thinking on:

 1. Compile and spit bitecode from the JIT the first time, load it on
 subsequent sessions. Seems doable. Doesn't work if your goal is
 using code on non-LLVM-aware applications, but if you want to do this
 the JIT is of no use anyways.

 2. Act as a traditional compiler and generate a shared library via
 llvmc + assembler + linker. Tricky, even more so on Windows. Resolving
 symbols is not as easy as is on case 1.

> Or would it be straightforward to write my own DLL writer (no advanced
> features needed)? Or maybe I could use an external linker? All help highly
> appreciated!

If you end hacking a DLL writer, please contribute it to LLVM :-)

-- 
Óscar




More information about the llvm-dev mailing list