[Mono-devel-list] Add /addmodule: support to mcs

Peter Ross pro at missioncriticalit.com
Sun Dec 21 06:30:52 EST 2003


On Thu, Dec 18, 2003 at 12:55:45PM +0100, Paolo Molaro wrote:
> On 12/18/03 Peter Ross wrote:
> > > 
> > > > I was wondering if anyone can give me any pointers on what would need to
> > > > be done to add /addmodule support to mcs?
> [...]
> > My plan is to look at monodis, factor out some of the code into a
> > library, build a .NET assembly above the library using PInvoke and then
> > integrate the library into mcs.
> 
> The library already exists, the code is in metadata/.
> 
Thanks.

> > Why am I doing this?  I would like to get Mercury [1] building under
> > Mono, and for that I need a C# compiler that accepts /addmodule and a
> > minimal implementation of al.exe.
> 
> Didn't the mercury compiler generate IL code? Or does it generate both
> IL and C# code?
> 
The compiler generates IL, but one can also specify that the
implementation of a function is in a foreign language.  We use this to
do some of the low level stuff (IO, sockets, etc., etc.) is in the
standard library.  Thus some of the mercury standard library is written
in C#, which is placed into modules, which are then linked together by
al.exe to form the assembly mercury.dll.


> I think the way to go is to implement the Assembly::LoadModule()
> method. It may be that the MS runtime already supports the kind of use
> we need to implement /addmodule.
> Anyway, the implementation of the method should work in the context of
> an AssemblyBuilder: when mcs creates the Assemblybuilder, it just
> uses abuilder.LoadModule (...) for each /addmodule argument.
> The loaded module gets added to the modules for the assembly builder
> and things should mostly work ok, but no doubt some changes will be
> needed, both when doing type lookups and when writing the pe file...
> al.exe, I think, could be implemented with the same trick.
> Alternatively, al.exe could be probably written using PEAPI.dll
> instead of Reflection.Emit.
> Another related (but minor) issue is getting mcs to create modules:
> we can probably overload the assembly builder flags to add a Module
> item, so Reflection.Emit will emit a module instead of a full assembly
> in that case.
> 
Thanks for this tips, I will look further into this.




More information about the Mono-devel-list mailing list