[MLton] Callbacks

Stephen Weeks MLton@mlton.org
Fri, 16 Jan 2004 18:46:40 -0800

> Built a new Cygwin mlton in roughly 1 1/2 to 2 hours after removing
> the doc target on a 2.4GHz PIV with 512 Mb and oddles of disk.  The
> build does bring all other processes to a grindingly slow pace
> (partial window redraws etc.)

Unfortunate.  I do a clean bootstrap on an unloaded 1.6GHz virtual
machine with 492M running Cygwin in about 35 minutes.  I guess you are
losing a lot of time to paging, which MLton is not smart about yet.
You could try setting ram-slop in mlton/Makefile to a slightly smaller
number -- .6 or maybe even .5, but no smaller.

> I had to download the Cygwin GMP library using the Cygwin setup program.

Why?  Weren't the gmp.h and libgmp.a that come with MLton enough?

> While linking my tests I got a bunch of unresolved GMP imports :
> /usr/lib/mlton/self/libmlton.a(gc.o)(.text+0x54dd):gc.c: undefined reference
> to
> `__imp____gmpn_set_str'

If I use the gmp 4.1.2 that comes via Cygwin's setup.exe, I get the
same error.
> Is there some special version of libgmp which you are using on Cygwin?

Yes.  When I started building MLton packages for Cygwin, I built
libgmp.a from the 4.0.1 sources.  It is that libgmp.a and gmp.h that
have been included in Cygwin packages since. I haven't upgraded or
switched over to the Cygwin gmp ... which seems good, since it has the
undefined reference problem above.

Looking more into the problem, I see that the gmp dll that comes via
Cygwin's setup is missing __imp____gmpn_set_str.

% nm /usr/lib/libgmp.dll.a | grep gmpn_set_str
00000000 T ___gmpn_set_str
00000000 I __imp____gmpn_set_str

I don't know how to fix the DLL.  But, the libgmp.a seems fine.

% nm /usr/lib/libgmp.a | grep gmpn_set_str
         U ___gmpn_set_str
         U ___gmpn_set_str
         U ___gmpn_set_str
00000000 T ___gmpn_set_str

So, if we can just use the .a instead of the dll, we should be fine.
Looking at the gmp 4.1.2 sources, I see that the only difference
between the gmp.h that they build and the gmp.h that comes with Cygwin

< #define __GMP_LIBGMP_DLL  1
> #define __GMP_LIBGMP_DLL  0

So, if we change this line in /usr/include/gmp.h to tell gmp to not
use dll's, we should be fine.

I've gone ahead and upgraded the gmp that we distribute with MLton to
4.1.2 (with LIBGMP_DLL = 0).  So, you should either be able to use the
gmp that comes with MLton, or you can tweak the line in

Let me know how that goes.

BTW, I just built a Cygwin package with the new setup and all went