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:
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.
I've fixed one problem. LLVM was falling back to its IR interpreter because
the native target was not initialized correctly. The solution is to call the
following three functions in turn:
LLVMInitializeX86TargetInfo
LLVMInitializeX86Target
LLVMInitializeX86TargetMC
Cheers,
Jon.
From: llvmdev-bounces@cs.uiuc.edu [mailto:llvmdev-bounces@cs.uiuc.edu] On
Behalf Of Jon Harrop
Sent: 04 March 2012 15:39
To: llvmdev@cs.uiuc.edu
Subject: [LLVMdev] LLVM from .NET
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.