[m-dev.] IL, Mono and Portable .NET

Jonathan Morgan jonmmorgan at gmail.com
Sat Feb 18 23:39:29 AEDT 2006


On 2/17/06, Julien Fischer <juliensf at cs.mu.oz.au> wrote:
>
>
> On Thu, 16 Feb 2006, Jonathan Morgan wrote:
>
> > On 2/11/06, Jonathan Morgan <jonmmorgan at gmail.com> wrote:
> > >
> > >
> > > For your information, I have just been trying the latest rotd, and MS
> > > ilasm breaks as well when compiling injection.m.  So maybe I'll
> backport
> > > your change to mercury-0.12.2 and try it with that (as I know MS ilasm
> can
> > > handle it).
> > >
> > > Jon
> > >
> >
> > I have used DotGnu on Win32, with mercury-0.12.2 on Cygwin.  It seems to
> go
> > all right compiling the IL, but breaks when building C# code, because it
> > doesn't have the /addmodule command line option.  I'll look into what we
> can
> > do to fix that (if anything).
> >
>
> That's was more or less where I ended up  with it.


As I said, it is possible to use the -fmodule=  option.  Here I'll put a
dump of my experiences in case someone more knowledgable than I knows what
to do.


cscc  /t:library /lib:`cygpath -w -a
/installs/mercury-compiler-0.12.2/tmp_dir/library`
\
    /out:array__csharp_code.dll `echo "/addmodule:mercury_dotnet.dll
/addmodule:mercury_il.dll /addmodule:array.dll /addmodule:assoc_list.dll
/addmodule:benchmarking.dll /addmodule:bool.dll
/addmodule:builtin.dll/addmodule:
char.dll /addmodule:construct.dll /addmodule:deconstruct.dll /addmodule:
dir.dll /addmodule:enum.dll /addmodule:exception.dll
/addmodule:float.dll/addmodule:
int.dll /addmodule:integer.dll /addmodule:io.dll /addmodule:lexer.dll/addmodule:
list.dll /addmodule:map.dll /addmodule:math.dll /addmodule:ops.dll/addmodule:
parser.dll /addmodule:private_builtin.dll /addmodule:random.dll /addmodule:
require.dll /addmodule:rtti_implementation.dll
/addmodule:set.dll/addmodule:set_ordlist.dll
/addmodule:set_tree234.dll
/addmodule:set_unordlist.dll /addmodule:std_util.dll
/addmodule:store.dll/addmodule:
string.dll /addmodule:svmap.dll
/addmodule:svset.dll/addmodule:table_builtin.dll /addmodule:
term.dll /addmodule:term_io.dll /addmodule:time.dll
/addmodule:tree234.dll/addmodule:type_desc.dll /addmodule:
varset.dll" | sed 's/\/addmodule:/-fmodule=/g'` /t:module
array__csharp_code.cs

Note that array__csharp_code.dll did in fact compile.

cscc  /t:library /lib:`cygpath -w -a
/installs/mercury-compiler-0.12.2/tmp_dir/library`
\
    /out:builtin__csharp_code.dll `echo "/addmodule:mercury_dotnet.dll
/addmodule:mercury_il.dll /addmodule:builtin.dll
/addmodule:array.dll/addmodule:assoc_list.dll /addmodule:
benchmarking.dll /addmodule:bool.dll /addmodule:char.dll /addmodule:
construct.dll /addmodule:deconstruct.dll /addmodule:dir.dll /addmodule:
enum.dll /addmodule:exception.dll /addmodule:float.dll
/addmodule:int.dll/addmodule:
integer.dll /addmodule:io.dll /addmodule:lexer.dll
/addmodule:list.dll/addmodule:
map.dll /addmodule:math.dll /addmodule:ops.dll
/addmodule:parser.dll/addmodule:private_builtin.dll /addmodule:
random.dll /addmodule:require.dll /addmodule:rtti_implementation.dll
/addmodule:set.dll /addmodule:set_ordlist.dll /addmodule:set_tree234.dll
/addmodule:set_unordlist.dll /addmodule:std_util.dll
/addmodule:store.dll/addmodule:
string.dll /addmodule:svmap.dll
/addmodule:svset.dll/addmodule:table_builtin.dll /addmodule:
term.dll /addmodule:term_io.dll /addmodule:time.dll
/addmodule:tree234.dll/addmodule:type_desc.dll /addmodule:
varset.dll" | sed 's/\/addmodule:/-fmodule=/g'` /t:module
builtin__csharp_code.cs
builtin.m:512: `mercury_code' is not a member of the namespace
`mercury.builtin'

builtin.m:512: called object is not a method or delegate

builtin.m:594: `mercury_code' is not a member of the namespace
`mercury.builtin'

builtin.m:594: called object is not a method or delegate

builtin.m:595: invalid return value

builtin.m:605: `runtime' is not a member of the namespace `mercury'

builtin.m:605: `runtime' is not a member of the namespace `mercury'

builtin.m:605: invalid left operand to `.'

builtin.m:605: called object is not a method or delegate

builtin.m:613: `runtime' is not a member of the namespace `mercury'

builtin.m:613: `runtime' is not a member of the namespace `mercury'

builtin.m:613: invalid left operand to `.'

builtin.m:613: called object is not a method or delegate

builtin.m:621: `runtime' is not a member of the namespace `mercury'

builtin.m:621: `runtime' is not a member of the namespace `mercury'

builtin.m:621: invalid left operand to `.'

builtin.m:621: called object is not a method or delegate

builtin.m:629: `runtime' is not a member of the namespace `mercury'

builtin.m:629: `runtime' is not a member of the namespace `mercury'

builtin.m:629: invalid left operand to `.'

builtin.m:629: called object is not a method or delegate

builtin.m:638: `runtime' is not a member of the namespace `mercury'

builtin.m:638: `runtime' is not a member of the namespace `mercury'

builtin.m:638: invalid left operand to `.'

builtin.m:638: called object is not a method or delegate

builtin.m:646: `runtime' is not a member of the namespace `mercury'

builtin.m:646: `runtime' is not a member of the namespace `mercury'

builtin.m:646: invalid left operand to `.'

builtin.m:646: called object is not a method or delegate

builtin.m:654: `runtime' is not a member of the namespace `mercury'

builtin.m:654: `runtime' is not a member of the namespace `mercury'

builtin.m:654: invalid left operand to `.'

builtin.m:654: called object is not a method or delegate

builtin.m:662: `runtime' is not a member of the namespace `mercury'

builtin.m:662: `runtime' is not a member of the namespace `mercury'

builtin.m:662: invalid left operand to `.'

builtin.m:662: called object is not a method or delegate

However, builtin's C# code will not compile, and it is unable to find the
namespaces.  Any ideas why one would and the other wouldn't?

make[2]: *** [builtin__csharp_code.dll] Error 1
make[2]: Leaving directory `/installs/mercury-compiler-0.12.2
/tmp_dir/library'
To clean up from failed install, remove tmp_dir
make[1]: *** [install_grades] Error 1
make[1]: Leaving directory `/installs/mercury-compiler-0.12.2'

Next step, I gave up on the install and started writing a custom command
line for builtin C# code, ending up with something like the following:

cscc /t:library -L "C:\cygwin\installs\mercury-
compiler-0.12.2\tmp_dir\library" -o builtin__csharp_code.dll
-fmodule=mercury_dotnet.dll -fmodule=mercury_il.dll
-fmodule=builtin.dll-fmodule=
array.dll -fmodule=assoc_list.dll -fmodule=benchmarking.dll -fmodule=
bool.dll -fmodule=char.dll -fmodule=construct.dll
-fmodule=deconstruct.dll-fmodule=
dir.dll -fmodule=enum.dll -fmodule=exception.dll -fmodule=float.dll-fmodule=
int.dll -fmodule=integer.dll -fmodule=io.dll -fmodule=lexer.dll -fmodule=
list.dll -fmodule=map.dll -fmodule=math.dll -fmodule=ops.dll -fmodule=
parser.dll -fmodule=private_builtin.dll -fmodule=random.dll -fmodule=
require.dll -fmodule=rtti_implementation.dll
-fmodule=set.dll-fmodule=set_ordlist.dll -fmodule=set_tree234.dll
-fmodule=set_unordlist.dll
-fmodule=std_util.dll -fmodule=store.dll -fmodule=string.dll -fmodule=
svmap.dll -fmodule=svset.dll -fmodule=table_builtin.dll
-fmodule=term.dll-fmodule=term_io.dll -fmodule=
time.dll -fmodule=tree234.dll -fmodule=type_desc.dll
-fmodule=varset.dll/t:module builtin__csharp_code.cs

This failed similarly.  I tried replacing /t:library with -shared (from the
cscc documentation) but it refused to recognise it.  I couldn't find an
equivalent option to /t:module - though I presume there must be one, since
it has the -fmodule flag.

Next, I decided to try MS csc with the DotGnu ilasm generated DLLs.  When
giving it the standard command-line, it complained that all the modules I
was referencing were actually assemblies, and advised me to use /R
(reference assembly, rather than addmodule).  After changing this it
compiled perfectly.  I presume that this means that DotGnu ilasm is creating
its DLLs differently from how MS ilasm does - though whether that is
affecting cscc is not anything that I can judge.

My feeling is that it's probably possible to patch up this rough hack to the
extent that it can build the C# code (it can currently build all the il it's
given before getting to the C#), but I do not have the necessary knowledge
to do so.

After that there is the fun of duplicating all the changes for Mono,
modifying the compiler for mmc --make and probably generate-dependencies as
well, and (I suggest) adding a compiler option to disable MC++ (is this
likely to affect mmake?  Will it try to build cpp_code files that aren't
there?).

I recommend looking at how a pre-existing tool (eg. csant) handles
command-lines for the different compilers.  However, I don't know what you
do if the various ilasms behave differently, as they will all be detected as
ilasm (you might be able to base it on the C# compiler, assuming that the
same IL compiler is used).

> Incidentally, I also notice that DotGnu installs al (which is identical to
> > ilalink) as well as ilalink, at least on DotGnu/Win32.
> >
>
> Hmmm ... it wasn't nice enough to do that for me on Linux.
>

On Windows they are more interested in moving over those anti-social people
who use Microsoft products :).

Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/developers/attachments/20060218/8a8a854e/attachment.html>


More information about the developers mailing list