[MLton] Windows port of MLton using the Microsoft tools (e.g. without MinGW)

Nicolas Bertolotti nicolas.bertolotti at polyspace.com
Thu Jul 26 04:17:04 PDT 2007


Hi,

 

I'm interested in getting a Win64 version of MLton. Now the 64 bits port for
Linux (and also other targets as I could read some messages about it on the
mailing list) is getting stable, I guess it should not be too complex to
update the MinGW port of MLton for Win64.

 

Unfortunately, MinGW is not yet available for Win64. The gcc port is
definitely not stable (the binutils seem to run fine) and the MinGW headers
and libraries are still experimental.

 

The fact we need MinGW to use MLton on Windows seems to be an obstacle in
terms of portability and the fact it does not require it anymore would make
life (at least mine ;-)) easier.

 

Has anyone ever tried to build a version of MLton that would use the
Microsoft tools instead of gcc and gas ?

 

I've personally tried to evaluate the amount of work that would be needed by
doing the following :

-          port the GNU MP library in order to build it using the Microsoft
C compiler

-          port the MLton runtime to build it using the Microsoft C compiler
:

o        update the Makefile

o        use the macro _MSC_VER to identify the target instead of other
macros such as __MINGW32__ or __i386__

o        convert the MLton runtime C code to C89 (it is written in C99 which
leads to a number of minor issues)

o        include the code for some MinGW specific extensions in the MLton
runtime (opendir/readdir/closedir/rint etc .)

o        take into account the fact that the CRT functions which are
equivalent to some LIBC functions are prefixed with an '_' 

-          update the basis library in order to add a "Win32" OS (quite
similar to the "MinGW" OS)

-          write a perl script that fixes the C code MLton generates in
order to build it using the Microsoft C compiler :

o        the generated C code may define some empty arrays which are not
accepted by the Microsoft compiler

o        some generated strings can be too big to be compiled using the
Microsoft compiler

-          write a perl script that converts the assembly code MLton
generates in order to build it using the Microsoft assembler

 

Using all this stuff and the files MLton produces when we use the "-stop g"
option, I could build some test binaries. Well, It is a bit complex but as I
mentioned above, my goal is not yet to port MLton but to evaluate the amount
of work that is needed to do so.

 

Unfortunately, the binaries I get by doing this always crash at the
beginning of the execution.

 

As I'm not really an expert in using the Microsoft assembler, I tried to
simplify this a bit by skipping the assembly code conversion script and
using the GNU assembler anyway (but still compile the runtime and link using
the Microsoft tools).

 

This time, I could get some binaries (even some big ones) that run pretty
fine.

 

Now, I'm a stuck because I really don't know how to solve the remaining
issues so, I would really appreciate your comments and suggestions.

 

Best regards

 

Nicolas Bertolotti

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mlton.org/pipermail/mlton/attachments/20070726/9bd6516b/attachment.htm


More information about the MLton mailing list