[MLton] Newer cygwin build of MLton?

Matthew Fluet fluet at tti-c.org
Sat Jul 12 12:40:56 PDT 2008


On Sat, 12 Jul 2008, Lars Bergstrom wrote:
> Is there either a newer cygwin build of MLton that includes some of the 
> recent Windows FFI fixes

No.

> or can somebody point me at instructions on how to 
> bootstrap MLton under cygwin using SML/NJ?

make nj-mlton ; make  # from the top-level Makefile

Also see
   http://mlton.org/CompilingWithSMLNJ

And be prepared to wait a while for the SML/NJ compiled MLton to compile 
MLton.  Of course, if you are interested in compiling a program other than 
MLton, after 'make nj-mlton', you'll have a '<src>/build/bin/mlton' that 
can be used to compile programs.  This SML/NJ compiled MLton will be 
slower than a MLton compiled MLton, but possibly a faster route to your 
final goal than bootstrapping.

> I'm trying to compile some MLton projects under cygwin that make heavy use of 
> OpenGL & GLUT, and am running into issues with it generating incorrect symbol 
> imports. In particular, it's looking for stuff like _glMatrixMode at 16 instead 
> of _glMatrixMode at 4. I'm assuming it's related to some of the other fixes for 
> the Windows FFI where it was mis-estimating the number of bytes being passed 
> to functions.

I don't think there have been any fixes to the Windows FFI since 20070826 
that would affect the treatment of stdcall functions.

But, it looks like the 16-byte alignment is bumping the size of the actual 
argument area, but also being used in the stdcall name mangling.  You 
probably need to patch like the following:

===================================================================
--- x86-generate-transfers.fun  (revision 6671)
+++ x86-generate-transfers.fun  (working copy)
@@ -1187,7 +1187,7 @@
                               (AppendList.append (assembly_arg, assembly_args),
                                size_arg + size_args)
                            end)
-                     val (pushArgs, size_args) =
+                     val (pushArgs, aligned_size_args) =
                          let
                             val space = 16 - (size_args mod 16)
                          in
@@ -1374,13 +1374,13 @@
                          (Assembly.directive_return
                           {returns = Operand.cReturnTemps returnTy})
                       val fixCStack =
-                        if size_args > 0
+                        if aligned_size_args > 0
                             andalso convention = CFunction.Convention.Cdecl
                             then (AppendList.single
                                   (Assembly.instruction_binal
                                    {oper = Instruction.ADD,
                                     dst = c_stackP,
-                                   src = Operand.immediate_int size_args,
+                                   src = Operand.immediate_int aligned_size_args,
                                     size = pointerSize}))
                             else AppendList.empty
                       val continue



More information about the MLton mailing list