Hi all,
is there a way to link a native static library (.a) into code that
runs through MCJIT? I was able to do it with LLVM 3.2, but it seems
the API has changed and maybe was removed?
Thanks,
Robin
Hi all,
is there a way to link a native static library (.a) into code that
runs through MCJIT? I was able to do it with LLVM 3.2, but it seems
the API has changed and maybe was removed?
Thanks,
Robin
What API did you use in 3.2?
I've never tried this, but I think it's probably possible.
-Andy
llvm::Linker used to have a method LinkInLibrary(). My understanding
is that there's a larger reorganisation of the linking process going
on but I haven't found a straight-forward replacement for that method
yet. I might be missing something though. Or perhaps I could even just
reuse some code from that old method; need to look at that.
Robin
OK, so in the old implementation you linked a module against the archive before passing it to MCJIT?
I'm not familiar with the llvm::Linker interface, so I hope someone else will jump in an address that.
I can think of a way to solve this inside MCJIT, but it is almost certainly not what you'd want.
-Andy
OK, so in the old implementation you linked a module against the
archive before passing it to MCJIT?
Yes, I used a Linker instance to link together a number of my own
modules and a static library, and then get a single new LLVM module
out of that to hand over to MCJIT.
I can think of a way to solve this inside MCJIT, but it is almost
certainly not what you'd want.
Whatever makes the symbols from the .a available to the MCJITed code
would work for me, but I can't tell if that's better done inside or
outside of MCJIT itself.
Robin
What I had in mind inside MCJIT was loading the archive file using RuntimeDyld and then using a custom MCJITMemoryManager to link against it. This is very heavy-handed and results in everything in the archive being loaded into memory whether it's needed or not. So I think it would be better to handle this before invoking MCJIT.
It looks like Daniel Dunbar made the commit that removed LinkInLibrary. Perhaps he can explain the motivation and possible alternatives.
-Andy