how to call the function in hosting code from JITted IR code..?


I’m trying to call the function that defined in the host application from IR code, but LLVM is saying that there is no such function…

I’ve seen the tutorial of Kaleidoscope, and defined the function as
extern “C” {
void test1(void) {
cout << “test function in the host application \n” ;

…in the host application.

Would you please let me give any idea or comment for this topic…?

thanks, regards…

1.If you’re on Windows,particularly x86 one,you have to check whether the function test1 is renamed to _test1 in your executable.
2.You have to append parameters like -fpic -rdynamic to make sure that your function is to be exported.And if you don’t want to do so,you may have to call llvm::sys::DynamicLibrary::AddSymbol() or create your own MemoryManager.

Hi, Waxiadao.

thank you, it works…!!