[MLton] MLton on intel mac

Matthew Fluet fluet at cs.cornell.edu
Mon Sep 18 15:36:33 PDT 2006


> I've been working on trying to get MLton to run on Intel macs.

Great.

> I think I've resolved most of the issues, and the last one facing me is 
> the alignment of stack frames.

Yes, we heard that there was a slightly different calling convention for 
MacOSX.

> The Mach-O dyld library uses sse instructions, among them movaqs.  This 
> causes general protection traps if it attempts to save to a stack address not 
> aligned on a 16-byte boundary.

Fair enough.

> This is probably a one-liner, but I'm just not familiar with the compiler's 
> internals enough to know how to change it quickly.  If someone could 
> demonstrate this, I could probably have an intel mac build up and running 
> fine.

You'll need to modify:
  mlton/codegen/x86-codegen/x86-generate-transfers.fun
The implementation of C-calls is lines 1066 -- 1368.  Within that code, 
the variable size_args calculates the size that the stack pointer has been 
moved in pushing arguments; my guess is that you can just round this value 
up to the nearest 16byte multiple and add the difference to esp.




More information about the MLton mailing list