[MLton] Question on Investigating Segfaults in Compiler

Stephen Weeks MLton@mlton.org
Thu, 8 Jul 2004 20:02:57 -0700


> I'm running into trouble here already.  For some
> reason, gcState is not being built into the runtime
> properly
...
> $ gcc -o 1.exe 1.0.o 1.1.o -L. -lmlton -lgmp -lgdtoa
> 1.0.o(.text+0x2):1.0.S: undefined reference to
> `gcState'
...
> I've grepped around a bit, but don't see where gcState
> (for example) is actually allocated.  If you can point
> me in the right direction, I'll be able to figure out
> what's not being built.

gcState is defined in one of the C files generated by MLton.  If you
compile with -keep g, you can find it.

Not sure whether you're using -codegen c or -codegen native, but with
the native codegen, there are a couple of tweaks due to different
treatment of labels on Cygwin.  You may need to apply those tweaks to
MinGW as well.  Have a look for "!targetOS = Cygwin" in files in
mlton/codegen/x86-codegen/.