I hit the MLton-wall! :)

Stephen Weeks MLton@sourcelight.com
Wed, 24 Jan 2001 10:41:36 -0800 (PST)


> I have now hit the MLton-wall with a software
> project. The project is about 23.000 lines of
> ML code... It compiles just fine under Linux,
> but when crosscompiling to Windows the
> assembler can't handle the .o files generated
> from gcc:
...
> Do you know of any solutions to this?
> Like splitting up the generated code into
> smaller pieces? 

We have split C files manually before, but have never written code to do it.
The C file that MLton generates consists of a bunch of global declarations
followed by C procedures, each of which can be placed in a separate file that
includes the global declarations.  You have to make the right things extern, but
it's not hard.

Another possibility is to turn down some of the optimizations that cause the
code size to increase, although this will cost you performance.  Try
-no-polyvariance and/or -inline 25 (or something else smaller than 50).  You can
get some amount of shrinkage there.

> Also - it happened when adding just a few more lines
> of code, so I'm not sure if some of the few differences
> in the Windows vs. Linux runtime system makes the
> difference - and that a similar limit on Linux is
> close...

I don't think so.  The compiler itself is up to 85,000 lines of code and we've
compiled it as one C file with no problems, although the assembler gets very
slow on large files.

As to doing things automatically, our new native backend, which is about to be
released, generates separate assembly files, so it should eliminate this
problem.  Hopefully you can easily turn it into a cross compiler as well?