[Mono-dev] Mono on armel/nokia 770 2006 OS

Paolo Molaro lupus at ximian.com
Mon Nov 20 13:06:46 EST 2006

Starting with Mono version 1.2.1, the Mono JIT supports the new ARM ABI
(also called gnueabi or armel). This is the same ABI used by the 2006 OS
update of the Nokia 770 and it should be good news for all the people
that asked me about having Mono run on their newly-flashed devices.

The changes involved enhancing the JIT to support soft-float targets
(this work will also help people porting mono to other embedded
architectures without a hardware floating point instruction set) as well
as the ARM-specific call convention changes. There was also some
hair-pulling involved, since the gcc version provided with scratchbox
goes into an infinite loop while compiling the changed mini.c sources
when optimizations are enabled, but I'm sure you don't want to know the

This was not enough, though, to be able to run Gtk# applications on the
Nokia 770. When I first ran a simple Gtk# test app I got a SIGILL inside
gtk_init() in a seemlingly simple instruction. Since this happened
inside a gcc-compiled binary I had no idea what the JIT could have been
doing wrong. Then this morning I noticed that the instructions in
gtk_init() were two bytes long: everything became clear again, I needed
to implement interworking with Thumb code in the JIT. This required a
few changes in how the call instructions are emitted and at callsite
patching. The result is that now Mono can P/Invoke shared libraries
compiled in Thumb mode (mono itself must still be compiled in ARM mode:
this should be easy to fix, but there is no immediate need now for it).
Note that this change didn't make it to the mono 1.2.1 release, you'll
have to use mono from svn.

As part of this work, I also added an option to mono's configure to
disable the compilation of the mcs/ directory, which would require
running mono in emulation by qemu inside scratchbox. The new option is
--disable-mcs-build. This can also be useful when building the runtime
on slow boxes, if the building of the mcs/ dir is not needed (common for
embedded environments where the managed assemblies are simply copied
from an x86 box).

There are not yet packages ready for the Nokia 770, though I'll provide
a rough tarball of binaries soon: the issue is that at least my version
of scratchbox has a qemu build that fails to emulate some syscalls used
by mono, so it's hard to build packages that require mono or mcs to be
run inside scratchbox. I'm told this bug has been fixed in more recent
versions, so I'll report how well jitted code runs in qemu when I'll
install a new scratchbox. This is not the best way to handle this,
though, because even if qemu can emulate everything mono does, it would
be very slow and silly to run it that way: we should run mono on the
host, just like we run the cross-compiling gcc on the host from inside
scratchbox and make it appear as a native compiler. From a quick look at
the documentation, it should be possible to build a mono devkit for
scratchbox that does exactly this. This would be very nice for building
packages like Gtk# that involve both managed assemblies and unmanaged
shared libraries (the Gtk# I used for testing required lots of painful
switches between scratchbox for compiling with gcc and another terminal
for running the C#-based build helper tools and mcs...). So, if anyone
has time and skills to develop such a devkit, it will be much
appreciated! Alternatively, we could wait for debian packages to be
built as part of the debian project's port to armel, which will use
armel build boxes.



lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better

More information about the Mono-devel-list mailing list