Hi all, I have some code that uses the x86 JIT via the C bindings that I'm trying to migrate from targeting LLVM 2.5 to the top of tree, but I'm running into a linking problem I can't figure out. Here's how I'm invoking the JIT in 2.5. LLVMInitializeNativeTarget(); <-- for the updated version LLVMCreateMemoryBufferWithContentsOfFile("code.bc", &buffer, &err); LLVMGetBitcodeModuleProvider(buffer, &provider, &err); LLVMCreateJITCompiler(&engine, provider, 1, &err); After that LLVMFindFunction and RunFunction work wonderfully on 2.5. The TOT version errors out on the CreateJITCompiler call with a "JIT has not been linked in" message. I'm compiling it as follows, which completes with no errors on either LLVM version. LLVM_CONFIG=<the llvm-config from the version I want to use> gcc `$LLVM_CONFIG --cflags` -o main.o -c main.c g++ `$LLVM_CONFIG --cflags` \ `$LLVM_CONFIG --ldflags` \ main.o `$(LLVM_CONFIG) --libfiles engine BitReader` Am I missing some other post 2.5 API change or am I building things wrong? Thanks, - Dave
Keppler, Dave wrote:> Hi all, > > I have some code that uses the x86 JIT via the C bindings that I'm trying to migrate from targeting LLVM 2.5 to the top of tree, but I'm running into a linking problem I can't figure out. > > Here's how I'm invoking the JIT in 2.5. > > LLVMInitializeNativeTarget(); <-- for the updated version > LLVMCreateMemoryBufferWithContentsOfFile("code.bc", &buffer, &err); > LLVMGetBitcodeModuleProvider(buffer, &provider, &err); > LLVMCreateJITCompiler(&engine, provider, 1, &err); > > After that LLVMFindFunction and RunFunction work wonderfully on 2.5. The TOT version errors out on the CreateJITCompiler call with a "JIT has not been linked in" message. > > I'm compiling it as follows, which completes with no errors on either LLVM version. > > LLVM_CONFIG=<the llvm-config from the version I want to use> > gcc `$LLVM_CONFIG --cflags` -o main.o -c main.c > g++ `$LLVM_CONFIG --cflags` \ > `$LLVM_CONFIG --ldflags` \ > main.o `$(LLVM_CONFIG) --libfiles engine BitReader` > > Am I missing some other post 2.5 API change or am I building things wrong?Add "jit native" to the list of components you're passing to llvm-config. Nick
>> I'm compiling it as follows, which completes with no errors on either >LLVM version. >> >> LLVM_CONFIG=<the llvm-config from the version I want to use> >> gcc `$LLVM_CONFIG --cflags` -o main.o -c main.c >> g++ `$LLVM_CONFIG --cflags` \ >> `$LLVM_CONFIG --ldflags` \ >> main.o `$(LLVM_CONFIG) --libfiles engine BitReader` >> >> Am I missing some other post 2.5 API change or am I building things >wrong? > >Add "jit native" to the list of components you're passing to llvm-config. > >NickFor me 'jit native' and 'engine' produce equivalent lists of libraries. Did my code look correct otherwise? There must be something broken on my system if that's the case. - Dave
Reasonably Related Threads
- [LLVMdev] Problem initializing a JIT via C bindings
- [LLVMdev] Problem initializing a JIT via C bindings
- [LLVMdev] llvm-c: LLVMCreateExecutionEngine returning empty error message
- Correctly linking against libLLVM (single shared library build)
- [LLVMdev] dragonegg now requires clang