I have recently started experimenting with LLVM under MinGW. I have read the Kaleidoscope tutorial but now I'm having problems with external functions.
I'm declaring external functions like this:
const Type* doubleType = Type::getPrimitiveType(ctx, Type::DoubleTyID);
std::vector<const Type*> doubleParams;
doubleParams.push_back(doubleType);
FunctionType* doubleDouble = FunctionType::get(doubleType, doubleParams, false);
Function* SinFunction = Function::Create(doubleDouble, Function::ExternalLinkage, "sin", mod);
Where mod is the Module* and ctx is the LLVMContext&.
In this case, everything works properly. However, if I declare a function:
extern "C"
double my_cubic_transform(double x) {
return x*x*x;
}
And change the SinFunction declaration from using "sin" to using "my_cubic_transform"(without changing anything else), then I get:
LLVM ERROR: Program used external function 'my_cubic_transform' which could not be resolved
Changing my makefile to include the "-g" option no effect. The Kaleidoscope tutorial suggested this was possible in LLVM(at least for JIT, which I am using). So am I doing something wrong? If so, what?