[LLVMdev] LLVM from .NET

Jon Harrop jonathandeanharrop at googlemail.com
Sun Mar 4 09:04:19 PST 2012


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.

> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On
> Behalf Of Jon Harrop
> Sent: 04 March 2012 15:39
> To: llvmdev at 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.
> 
> --
> Dr Jon Harrop, Flying Frog Consultancy Ltd.
> http://www.ffconsultancy.com
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list