Cheng Zhu
2015-Jan-05 22:07 UTC
[LLVMdev] LLVM linkage error - Program used external function 'foo' which could not be resolved!
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. -- Best regards Cheng
mahesh ravishankar
2015-Jan-06 21:00 UTC
[LLVMdev] LLVM linkage error - Program used external function 'foo' which could not be resolved!
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. On Mon, Jan 5, 2015 at 2:07 PM, Cheng Zhu <chengzhu at gmail.com> wrote:> 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. > > -- > Best regards > > Cheng > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Mahesh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150106/6df8cc04/attachment.html>
Charlie Turner
2015-Jan-06 21:15 UTC
[LLVMdev] LLVM linkage error - Program used external function 'foo' which could not be resolved!
On 6 January 2015 at 21:00, mahesh ravishankar <mahesh.ravishankar at gmail.com> wrote:> sys::DynamicLibrary::AddSymbol("foo",(void*)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, http://blog.llvm.org/2013/07/using-mcjit-with-kaleidoscope-tutorial.html HTH, Charlie.