Hi Tim,
I am already using MCJIT. However, I am now confronted with architectures
where it's not straight-forward to cross compile LLVM to (and use it's
JIT'er).
Thus, I am exploring the detour over a shared lib.
Assuming that clang cooperates with the linker would it be sensible to
track what path is taken when specifying -shared -fPIC? This should give
me hints what is needed.?
Frank
On 11/12/13 12:19, Tim Northover wrote:> Hi Frank,
>
>> I'd like to create a shared library out of a module in memory.
Thus, I have
>> a working module and would like to produce a library similar to what
> That's not something LLVM can do on its own. You need a linker of some
> kind to create a shared library (to create appropriate GOT entries,
> resolve relocations, find dependent libraries, ...).
>
> LLVM includes a component called MCJIT which does some of this work,
> sort of, but it's in no way designed to output another object file at
> the end of the process, which would be needed. It's designed to fixup
> an object file in mostly ad-hoc ways so that it can be executed
> directly in memory.
>
> Other than that, you might have success linking against lld as a
> library in addition to base LLVM. The documentation there is likely to
> be even more sparse though (lld is reasonably new and embedding
> linkers is less popular than embedding compilers).
>
>> Where in the code (probably clang?!) is a good starting point to look?
>> 'Shared' and 'position-independent' would be important.
> Certainly you'd have to setup your target to compile PIC.
>
> Cheers.
>
> Tim.