[Mono-list] Mono Project - Native compiler request

Jonathan Pryor jonpryor@vt.edu
Fri, 08 Aug 2003 08:20:16 -0400

The mono equivalent of ngen.exe is:

	mono --aot --optimize=all <assembly/>

However, ngen.exe doesn't work the way you think it does.  It generates
native code, certainly, which can improve application load time.  But
that's all it does.  It doesn't remove a dependency from the runtime,
build static libs, or anything like that.  Strictly speaking, you can't
(well, shouldn't) copy the resulting binary between machines, as the
binary can be machine specific.  (Right Now, it's probably safe, but in
the future you can expect Athlon- or Pentium-specific optimizations,
which will limit portability between architectures.)

Why is this?  Because certain tasks *require* the runtime.  Reflection,
use of attributes, and runtime assembly loading all require the
runtime.  It may be possible to statically determine at compile time
which of these can be implemented, but doing so is a major task which no
one has done yet, and it's not likely to happen either.  (It's more
likely for more features requiring the runtime to be added, such as
generics, which uses runtime type instantiation, not compile-time type
instantiation, which C++ uses.)

However, if you're only concerned about a *single* .net application, and
you're willing to use mono, you could always just remove the assemblies
that you *know* you don't require, throw everything else into a
directory tree (with subdirectories of /bin, /lib, /etc, etc.), and
distribute that with your application bundled with it.

However, I'm not sure how long this will be possible with mono, as there
has been talk of using the Windows Registry to keep track of
installation paths, etc., which would complicate this scenario.

Additionally, as soon as you had a second .net application to
distribute, you'd have to do all that again, likely requiring more disk
space than if you had just installed the redistributable in the first

Sorry I can't be more optimistic about this...

 - Jon

On Fri, 2003-08-08 at 12:11, Jan wrote:
> Hi,
> I’d like to know if it‘s possible to develop a native compiler, e.g.
> similar to ngen.exe; The resulting project would not require the
> runtime framework to execute; or at least only a small subset of it –
> i.e. only the methods of the runtime used are extracted at compile
> time and included in a new static dll for deployment. Similar to
> msvcrt etc…
> My concern is that to deploy a .net application you must also deploy
> the runtime which carries a 20MB payload. 
> Regards
> Jan