Is there documentation somewhere on how to call external functions from llvm? The only guide I found was this: http://www.gearleaf.com/blog/post/44, and it doesn't seem to be working for me. I have a function: llvm::GenericValue lle_X_create_number_object(llvm::FunctionType* ft, const std::vector<llvm::GenericValue>& args) { llvm_object_structure* result = new llvm_object_structure; result->typeIdx = TypeSystem::number; result->data = reinterpret_cast<unsigned char*>(new double(args[0].DoubleVal)); llvm::GenericValue gv; gv.PointerVal = reinterpret_cast<void*>(result); return gv; } defined in an extern "C" block. I add it as a symbol with: llvm::sys::DynamicLibrary::AddSymbol("lle_X_create_number_object",(void*)lle_X_create_number_object); yet when attempting to call it I still get: "LLVM ERROR: Program used external function 'create_number_object' which could not be resolved!" -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100819/fd1dee4d/attachment.html>
o.j.sivart at gmail.com
2010-Aug-19 22:46 UTC
[LLVMdev] using external functions from llvm
You are adding the symbol as "lle_X_create_number_object" yet your error message implies you have tried to lookup and use "create_number_object". Can you provide the code for the lookup? On 20/08/2010, at 8:07 AM, Alec Benzer wrote:> Is there documentation somewhere on how to call external functions from llvm? The only guide I found was this: http://www.gearleaf.com/blog/post/44, and it doesn't seem to be working for me. > > I have a function: > > llvm::GenericValue lle_X_create_number_object(llvm::FunctionType* ft, const std::vector<llvm::GenericValue>& args) > { > llvm_object_structure* result = new llvm_object_structure; > result->typeIdx = TypeSystem::number; > result->data = reinterpret_cast<unsigned char*>(new double(args[0].DoubleVal)); > llvm::GenericValue gv; > gv.PointerVal = reinterpret_cast<void*>(result); > return gv; > } > > defined in an extern "C" block. I add it as a symbol with: > > llvm::sys::DynamicLibrary::AddSymbol("lle_X_create_number_object",(void*)lle_X_create_number_object); > > yet when attempting to call it I still get: "LLVM ERROR: Program used external function 'create_number_object' which could not be resolved!" > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100820/c046de8a/attachment.html>
The blog post I linked to implied that adding a symbol in the form lle_X_FUNCTIONNAME would allow you to call a function called FUNCTIONNAME. Is this not the case? On Thu, Aug 19, 2010 at 6:46 PM, <o.j.sivart at gmail.com> wrote:> You are adding the symbol as "lle_X_create_number_object" yet your error > message implies you have tried to lookup and use "create_number_object". Can > you provide the code for the lookup? > > On 20/08/2010, at 8:07 AM, Alec Benzer wrote: > > Is there documentation somewhere on how to call external functions from > llvm? The only guide I found was this: > http://www.gearleaf.com/blog/post/44, and it doesn't seem to be working > for me. > > I have a function: > > llvm::GenericValue lle_X_create_number_object(llvm::FunctionType* ft, const > std::vector<llvm::GenericValue>& args) > { > llvm_object_structure* result = new llvm_object_structure; > result->typeIdx = TypeSystem::number; > result->data = reinterpret_cast<unsigned char*>(new > double(args[0].DoubleVal)); > llvm::GenericValue gv; > gv.PointerVal = reinterpret_cast<void*>(result); > return gv; > } > > defined in an extern "C" block. I add it as a symbol with: > > > llvm::sys::DynamicLibrary::AddSymbol("lle_X_create_number_object",(void*)lle_X_create_number_object); > > yet when attempting to call it I still get: "LLVM ERROR: Program used > external function 'create_number_object' which could not be resolved!" > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100819/81b65942/attachment.html>