problem with execution engine on windows

Dear llvm-dev,

First of all I'd like to thank LLVM developers for doing a great job!

I am trying to use LLVM libraries on Windows using Visual Studio environment and everything works very smoothly until it comes to the execution engine. I construct a module and obtain a pointer to the function in it using ExecutionEngine::getPointerToFunction but calling this function (after appropriate cast) causes the following error:

Unhandled exception at 0x0122a5bc in sampl.exe: 0xC000001E: An attempt was made to execute an invalid lock sequence.

The function I am trying to call is trivial (took it from the tutorial just for testing purposes) and has C calling conventions. The execution engine returned by ExecutionEngine::create is Interpreter.

Am I doing something wrong or is it a bug?

And another question: is JIT supported on Windows?

Thank you in advance,
Viktar

"Viktar Zviarovich" <Viktar.Zviarovich@brunel.ac.uk> writes:

[snip]

The function I am trying to call is trivial (took it from the tutorial
just for testing purposes) and has C calling conventions. The
execution engine returned by ExecutionEngine::create is Interpreter.

Am I doing something wrong or is it a bug?

Are you using CMake for generating the Visual Studio project files? If
the answer is yes, please check

http://www.llvm.org/docs/CMake.html

specially the last section of the page.

And another question: is JIT supported on Windows?

Yes.

Yes, I am using CMake and the addition "/INCLUDE:_X86TargetMachineModule" compiler option as described in that document partially solved the problem, thank you. After some debugging and browsing the LLVM headers I finally solved it by including "llvm/ExecutionEngine/JIT.h". I would be helpful to document this as well.

Viktar