Wednesday, August 09, 2006

Compiling CLI language x to x86 native code using Mono

In a short article by Miguel de Icaza about running Java code under Mono, he discusses how to convert a Java program via IKVM to a CLI executable. And then with some mono magic turn it into native x86 code. This means if program in a language that generates CLI executables, you to generate a native x86 version.

For example, in my series of blog posts I created a GDATA reader with IronPython. You can create a executable from using the following command:

mono ipy.exe -X:SaveAssemblies gdatareader.py

This creates a gdatareader.exe. You will still need the gdata, IronPython and IronMath dll's but there is no longer the delay of IronPython loading the Python program and converting it to IL. To convert it to native x86 code, run the following command:

mono --aot gdatareader.exe

This creates a gdatareader.exe.so which contains the native x86 code. The gdatareader.exe is still used to start the program but the JIT compiler is not required, so some more CPU cycles are saved.

No comments: