Mono Class Libraries

Topics: General
May 3, 2009 at 11:57 PM

Based on the "MOSA Runtime, Kernel, and Plugging" discussion, I started to port the Mono class libraries for our use. Since we may need to do this frequently, I wrote a tool which automates the patching of the Mono class libraries in several ways: 1) all external methods are wrapped in conditional statements, 2) classes with external methods are turned into partial classes, and 3) those external methods declarations are put into partial files. I also built a minimal solution file and included three projects files for corlib, system and system.xml.

The patching tool works extremely well. Only 10 partial files require manual modifications to make the build succeed (out of over 14,500 total source files). Those exceptions are mostly because of fancy conditional statements that the tool is unable to understand.

I also wrote a tool to create all the Visual Studio project files but stopped work on that since Miguel de Icaza from the Mono project is incidentally working on that right now as part of their effort to build the class libraries with Visual Studio. The Mono build process is unique. To get around the cyclic dependencies between the class libraries, Mono builds the libraries several times adding additional dependencies during each build iteration. I don't understand it completely myself yet - but Mono's support for Visual Studio should help short-cut our own efforts and provide us with the rest of the project files and solution file.

Okay, here's how to get started with building the Mono Libraries.

1. Download the latest version of Mosa (include both the trunk and patchs directories) from SVN.
2. Execute the Start-133384.bat script in the \trunk\Setup\Mono directory.
3. Open the Mono solution file located at \trunk\Setup\Mono\build\mono-133384\mcs\class\Mosa.sln
4. Build it. The DLLs will be located afterwards in the \trunk\Setup\Mono\build\mono-133384\mcs\class\bin directory.

The script in step #2 is specific to 133384 revision from Mono's SVN. For convenience, that build has been archived in \patches\mono. If you wish to do this with other revisions from Mono, download the zipped tar to either \trunk\patches\mono or \trunk\Setup\Mono\src, and modify the Start-XXXX.bat script (it's trivial). The specific patches for r133384 most likely will work with other revision from Mono SVN. So copy the \trunk\Setup\Mono\Patches\133384 to another directory named after the revision number.

Obviously, this will get slightly complicated as we actually implement the partial methods for Mosa. Luckily, the core class libraries are standardized which means they are unlikely to be refactored and our incremental maintenance hopefully minimal.

Once Mosa gets traction, I think we could submit our patched class library files for inclusion in Mono (maybe even the new partial files for our platform). The conditional logic should not affect the existing Mono build process. So we might have a higher chance that our submission would be accepted.

Take a peak and give it a shot. We still have a long way to go before the MOSA compiler will be able to compile this and we need to determine the hooks into the VES.

- Phil

May 6, 2009 at 11:06 AM
fyi ~ I submitted our first patch to the Mono project to replace the InternalSplit() method with a managed version. Hopefully, it will be accepted. If not, it stays in the String.Partial.cs file.
May 6, 2009 at 3:28 PM
Great work!
Aug 5, 2009 at 7:44 PM

Would be great to be allowed to commit a managed version of all methods. They could put it in and enable ./configure --fullmanaged.

Aug 8, 2009 at 2:34 AM

Yes, that would be the ideal option. Once we get momentum, we will ask for cooperation and coordination with the mono project.