[LLVMdev] Using a function from another module
Michael Muller
mmuller at enduden.com
Sun Jan 10 06:58:29 PST 2010
Michael Muller wrote:
>
> Hi all,
>
> I'm trying to use a function defined in one LLVM module from another module
> (in the JIT) but for some reason it's not working out. My sequence of
> activity is roughly like this:
>
> 1) Create moduleA
> 2) Create moduleB with "func()"
> 3) execEng = ExecutionEngine::create(
> new ExistingModuleProvider(moduleB));
> 4) execute "func()" (this works fine)
> 4) add "func()" to moduleA as a declaration (no code blocks) with External
> linkage.
> 5) execEng->addModuleProvider(new ExistingModuleProvider(moduleA));
> 6) run a function in moduleA that calls "func()"
>
> I get:
> LLVM ERROR: Program used external function 'func' which could not be resolved!
>
> I'm guessing I'm either going about this wrong or missing something. Can
> anyone offer me some insight?
I've played around with this some more.
It looks like the only way that I can get this to work is to do an
ExecutionEngine::addGlobalMapping() on the function declaration in moduleA to
map it to the function pointer in moduleB.
This seems awkward, is there a better way to do this?
>
> =============================================================================
> michaelMuller = mmuller at enduden.com | http://www.mindhog.net/~mmuller
> -----------------------------------------------------------------------------
> We are the music-makers, and we are the dreamers of dreams
> - Arthur O'Shaughnessy
> =============================================================================
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
=============================================================================
michaelMuller = mmuller at enduden.com | http://www.mindhog.net/~mmuller
-----------------------------------------------------------------------------
you and I are only different in our minds, the universe makes no such
distinction
=============================================================================
More information about the llvm-dev
mailing list