[MLton] Re: MLton and shared libraries

Stephen Weeks MLton@mlton.org
Tue, 19 Apr 2005 16:14:20 -0700


> Then I spent some time foolishly editing include/c-main.h and
> friends until I found out that build/bin/mlton uses the include
> files in build/lib/include.

Yes, but those are copied from include by the "runtime" target in the
main Makefile.  I wouldn't recommend editing files in build/lib/.

> Looking at GC_init and MLton_init didn't make it clear to me what I
> kind of dummy arguments I need to use in init_function.

The ones you used don't seem obviously wrong to me.

> The catious reader might have noticed that the body of main
> actually starts like this:
...
>          if (gcState.isOriginal) {                                       \
>                  real_Init();                                            \
>                  PrepFarJump(mc, ml);                                    \
...
> The dummy arguments I used, implies that the false branch is taken.
> I figured that it should have been the true branch, so I removed
> the if-statement, but this might be a mistake?

No, you definitely want the isOriginal branch.

You could use gdb at this point to find out where the segfault is.

If that doesn't shed any light, another useful trick is to recompile
the runtime setting "DEBUG_ENTER_LEAVE = TRUE" in gc.c, and then
compile the SML code with "-profile call" (I believe you need the CVS
MLton for this to work).  This will cause a debugging message upon
entry and exit of every SML function.

Hopefully one of these will localize the problem.