InitializeNativeTarget

It seems that a client application needs to call
InitializeNativeTarget or LLVMInitializeNativeTarget before doing any
JITting. Unfortunately, LLVMInitializeNativeTarget is defined static
inline and does not appear in the .a files; thus a client not written
in C or C++ trying to JIT cannot link to the library and call
LLVMInitializeNativeTarget that way.

It can call a target-specific library function such as
LLVMInitializeX86Target, but this is obviously not portable.

Kenneth Uildriks wrote:

It seems that a client application needs to call
InitializeNativeTarget or LLVMInitializeNativeTarget before doing any
JITting. Unfortunately, LLVMInitializeNativeTarget is defined static
inline and does not appear in the .a files; thus a client not written
in C or C++ trying to JIT cannot link to the library and call
LLVMInitializeNativeTarget that way.

Yes, so you'll need to add a little C++ module to your wrapper that does
the necessary initializations and is callable from your target language.

Albert

That's odd, we don't need to do that for ocaml. Have you tried having
a function like this defined in your binding?

/* Force the LLVM interpreter and JIT to be linked in. */
void llvm_initialize(void) {
  LLVMLinkInInterpreter();
  LLVMLinkInJIT();
}

You don't have to call it, it's just there to make sure the execution
engine is actually linked with the binding library.

But that doesn't cause the native target to be registered with the
native target registry, does it?. Are you running against LLVM trunk?