[LLVMdev] LLVM from .NET

Jon Harrop jon at ffconsultancy.com
Sun Mar 4 07:38:31 PST 2012


I've been struggling to get LLVM to work from .NET using the llvm-fs
bindings for the past few weeks. I finally found an installation procedure
that works and documented it here:

http://fsharpnews.blogspot.com/2012/03/using-llvm-from-f-under-windows.html

The good news is that I have that program compiling the Fibonacci function
and executing it from F# all via LLVM.

However, I still have a couple of problems. Firstly, I was getting "stack
unbalanced" warnings from the managed debugging assistant when I run a debug
build. I managed to fix them on my (x86 Vista) desktop by specifying the
Cdecl calling convention but the warnings persist on my (x86 Win 7) netbook.
Secondly, the performance is awful which (IIRC) is probably because the
native target has not been initialized correctly and LLVM is falling back to
the IR interpreter. Keith Sheppard used a hack to call
LLVMInitializeX86Target but that hasn't done the trick and I cannot figure
out how to call the correct LLVMInitializeNativeTarget function from .NET.

Does anyone know the solutions to these problems or, better yet, have a
pre-existing .NET binding to LLVM where everything just works effortlessly?

FWIW, I tried running Microsoft's PInvoke Interop Assistant on LLVM-3.0.dll
in an attempt to generate .NET bindings automatically but it chokes on the
DLL.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com




More information about the llvm-dev mailing list