Hi, All
I got a linkage error as indicated in the subject line. Any suggestion?
I created a call builder.CreateCall2(foo, p1, p2) in a module. foo is
a Function* generated by module->getOrInsertFunction("foo",
prototype). foo is defined outside of this module, and in the dump of
the module, I see "declare i64 @foo(xxx, xxx)". The error happens
during link time, it seems like my jitted function couldn't find foo
function defined outside of the module jitted function existed.
If you are using MCJIT, then I have found that sometimes external function symbols are not resolved properly. I have used the following call with some success
sys::DynamicLibrary::AddSymbol(“foo”,(void*)foo);
i.e., mapping the name “foo” to the variable foo.
This solution could be suitable to your needs, but it's also possible
you'll run into name conflict problems.
An alternative approach is to subclass SectionMemoryManager and
override the getSymbolAddress function to search for the passed-in
name in all modules previously loaded, not just the current "open"
module.
An example of the latter approach that might be of interest to you is
on the LLVM blog,
HTH,
Charlie.