Mono Meeting

Posted by Jb Evain Wed, 13 Sep 2006 17:31:00 GMT

Thanks to db4o who is sponsoring my trip, I’ll be attending the Mono Meeting at the end of October. I’ll have two talks here:

  • One about db4o, the leading object database,
  • The other about Cecil, our assembly manipulation library.

See you there!

Mono.Cecil 0.4.3 released

Posted by Jb Evain Wed, 23 Aug 2006 22:58:00 GMT

Here is a new version of Cecil.

This is mainly a bug fix release, in the 0.4 serie, but if you look carefuly, you may find find one new feature or two. The bigger one is maybe an AssemblyResolver, which helps you find an assembly depending on its name. It’s quite simple, but so far, it worked great for the new linker.

It will be used in the next releases to read some parts of an assembly that depends upon informations in a referenced assembly.

Whatever, here are the interesting bits

Dear users, please upgrade.

Linking all the way down 10

Posted by Jb Evain Tue, 22 Aug 2006 20:44:00 GMT

Do you remember this post?

If you do so, I’m sure you know, what I’m going to show you. A formidable use of the new linker.

What do you need? First you need an application. I’ve reused a very small program I wrote a bunch of month with db4o. It simply allows you to persist a few objects Person in a db4o database, and to retrieve them. But it’s sooo cool that I’d like to make it a standalone application.

It has a very friendly command line interface:

Very nice isn’t it? So now, let’s link it so that I have the minimum set of the assemblies my program use.

jbevain@avalon:/tmp/linker$ mono linker.exe -o persons -a persons.exe -p false
jbevain@avalon:/tmp/linker$ cp persons.yap persons/
jbevain@avalon:/tmp/linker$ cd persons/

The yap file is db4o’s database.

Please note that in SVN, I’ve disabled the ability to link the assembly mscorlib.dll. It’s a very special assembly which is of course very close to the runtime. So if ever you want to remove stuff from it, you have to be very frugal, so you don’t remove stuff used within the runtime. And it seems that I’ve not identified everything used. So it tend to be pretty unstable :)

But for the time being, it’s fine. Now, let’s create a standalone application from this great piece of code.

jbevain@avalon:/tmp/linker/persons$ mkbundle
OS is: Linux
Sources: 0 Auto-dependencies: False
Usage is: mkbundle [options] assembly1 [assembly2...]

Options:
    -c              Produce stub only, do not compile
    -o out          Specifies output filename
    -oo obj         Specifies output filename for helper object file
    -L path         Adds `path' to the search path for assemblies
    --nodeps        Turns off automatic dependency embedding (default)
    --deps          Turns on automatic dependency embedding
    --keeptemp      Keeps the temporary files
    --config F      Bundle system config file `F'
    --config-dir D  Set MONO_CFG_DIR to `D'
    --static        Statically link to mono libs
    -z          Compress the assemblies before embedding.

jbevain@avalon:/tmp/linker/persons$ mkbundle -o persons --nodeps ./persons.exe ./db4o.dll ./mscorlib.dll
OS is: Linux
Sources: 3 Auto-dependencies: False
   embedding: /tmp/linker/persons/persons.exe
   embedding: /tmp/linker/persons/db4o.dll
   embedding: /tmp/linker/persons/mscorlib.dll
Compiling:
as -o /tmp/tmp47dda943.tmp.o temp.s
cc -ggdb -o persons -Wall temp.c `pkg-config --cflags --libs mono`  /tmp/tmp47dda943.tmp.o
Done
jbevain@avalon:/tmp/linker/persons$ mkdir standalone
jbevain@avalon:/tmp/linker/persons$ mv persons standalone/
jbevain@avalon:/tmp/linker/persons$ mv persons.yap standalone/
jbevain@avalon:/tmp/linker/persons$ cd standalone/
jbevain@avalon:/tmp/linker/persons/standalone$ ./persons
Persons manager
l
All persons:
Person, name: Anaelle, age: 19
Person, name: Jb Evain, age: 23
Person, name: Reg, age: 24
q
jbevain@avalon:/tmp/linker/persons/standalone$

Et voilĂ , we now have a standalone application that works like a charm, and which contains, well almost, only what’s needed to use it. That’s so great!

Ok, let’s go back to the code, I need to make the linking against corlib working.

Link to Link 6

Posted by Jb Evain Mon, 21 Aug 2006 15:24:00 GMT

Thanks to everyone who asked, I’m not dead. Well, not yet.

This year, I’m again involved in Google’s Summer of Code, working for the Mono project on the CIL Linker. A CIL Linker? What’s that? According to this page, here is a definition:

The idea is to create a “linker” for assemblies in Mono. The goal is to only ship the minimal possible set of functions that a set of programs might require to run as opposed to the full libraries.

So this “linker” is now working, more or less. You can find the code in the module /cecil/linker of Mono’s SVN.

If ever you want to try to compile it from the sources, you’ll have to checkout the lib module also, as it contains the library Cecil that I use to manipulate the assemblies that have to be linked.

Let me show you what it can do. Let’s link the linker!

porte:/tmp/linker jbevain$ ls -l
total 856
-rwxr-xr-x   1 jbevain  jbevain  395776 Aug 21 13:03 Mono.Cecil.dll
-rwxr-xr-x   1 jbevain  jbevain   38912 Aug 21 13:03 linker.exe
porte:/tmp/linker jbevain$ mono linker.exe 
Mono CIL Linker
linker [options] -x|-a file
   --about     About the Mono CIL Linker
   --version   Print the version number of the Mono CIL Linker
   -out        Specify the output directory, default to .
   -p          Preserve the core libraries, true or false, default to true
   -x          Link from an XML descriptor
   -a          Link from an assembly

   you have to choose one from -x and -a but not both
porte:/tmp/linker jbevain$ mono linker.exe -out linker_only -a linker.exe 
porte:/tmp/linker jbevain$ ls -l linker_only/
total 8232
-rw-r--r--   1 jbevain  wheel   364032 Aug 21 13:12 Mono.Cecil.dll
-rwxr-xr-x   1 jbevain  wheel  1068544 Aug 21 13:12 System.Xml.dll
-rwxr-xr-x   1 jbevain  wheel   760320 Aug 21 13:12 System.dll
-rwxr-xr-x   1 jbevain  wheel    38912 Aug 21 13:12 linker.exe
-rwxr-xr-x   1 jbevain  wheel  1975296 Aug 21 13:12 mscorlib.dll

So, what happened here is that the linker linked itself, plus third parties libraries, but without touching to the core. This could be useful to reduce the size of an application. But another goal of the linker is to create the really minimal set of assemblies in used. So let’s link the core also!

porte:/tmp/linker jbevain$ mono linker.exe -out linker_core -a linker.exe -p false
porte:/tmp/linker jbevain$ ls -l linker_core/
total 4792
-rw-r--r--   1 jbevain  wheel   364032 Aug 21 13:15 Mono.Cecil.dll
-rw-r--r--   1 jbevain  wheel   552448 Aug 21 13:15 System.Xml.dll
-rw-r--r--   1 jbevain  wheel   117248 Aug 21 13:15 System.dll
-rwxr-xr-x   1 jbevain  wheel    38912 Aug 21 13:15 linker.exe
-rw-r--r--   1 jbevain  wheel  1372672 Aug 21 13:15 mscorlib.dll

Et voilĂ , the core has been linked as well. Watch the size of the assemblies! Now what about using this linked linker! I’ll keep it simple for the moment, let’s link a simple hello world using this new linker:

porte:/tmp/linker/linker_core jbevain$ export MONO_PATH="/tmp/linker/linker_core/" 
porte:/tmp/linker/linker_core jbevain$ mono linker.exe -out hello -a hello.exe
porte:/tmp/linker/linker_core jbevain$ cd hello
porte:/tmp/linker/linker_core jbevain$ export MONO_PATH="/tmp/linker/linker_core/hello" 
porte:/tmp/linker/linker_core/hello jbevain$ ls
hello.exe       mscorlib.dll
porte:/tmp/linker/linker_core/hello jbevain$ mono hello.exe 
Hello World!

Pretty cool huh? I ever you want to give it a try and link the core, you have to know that you’re going to face some bugs, due to the fact that I modify the corlib. But heh, that’s a good start for the linker isn’t it?

Older posts: 1 ... 13 14 15 16 17