Im trying to register an extern function with clangs JIT without success.
Heres the function im trying to call:
extern "C"
int myFunction(int val)
{
fprintf(stderr, "success!");
return 1;
}
Heres the code im using to register it:
llvm::FunctionType* ft = llvm::FunctionType::get(llvm::Type::getInt32Ty(llvm::getGlobalContext()),
std::vector<const llvm::Type*>(1, llvm::Type::getInt32Ty(llvm::getGlobalContext())), false);
llvm::Function* F = llvm::Function::Create(ft, llvm::Function::ExternalLinkage, "yipee", Mod);
EE->addGlobalMapping(F, (void*)(intptr_t)yipee);
And heres the c code which will be ran by the JIT:
int myFunction(int);
int main()
{
int dd = myFunction(5);
return 0;
}
My code is not right or something else? Any ideas? Thanks.