Introducing the "lookup-constants runtime system" :)

Stephen Weeks MLton@sourcelight.com
Mon, 1 Oct 2001 12:35:41 -0700


> The lookup-constants program seems to be something
> like the following:
> 
> #include <stdio.h>
> #include <targetfile1>
> #include <targetfile2>
> ...
> struct GC_state gcState;
> int main (int argc, char **argv)
> {
>   FILE *f = fopen(argv [1], "w");
>   fprintf ...
>   fprintf ...
>   fclose(f);
> }
> 
> <stdio.h> has to be included for the HOST
> system (for the functions fopen, fprintf and fclose to work),
> while the other files are included for the TARGET system.

Agreed.

> The way that include directories are specified, are by using
> -Idir options for mlton. And these are directories for the
> target system. Now, we could search for the included files in
> those directories and insert explict paths to the #include directives -
> and use gcc -Idir flags for the host system. Conversely we could
> also add an explicit path instead of the #include <stdio.h>
> directive and add -Idir flags for the target system. But either way -
> directories included from those files are likely to search the wrong
> directories.

Why?  I like your option two (include the explicit path for #include <stdio.h>).
That way, the normal lookup-constants method can be used.  It seems like a minor
change the current approach to include the target headers (which I figure you
must have) and then run lookup-constants on the host system.  Combining that
with calling the cross-compiling gcc and linking with the right files seems to
me to be all you need.

> And by the way - why is struct GC_state gcState there?

No idea.  Vestigal, probably.  The only thing I can imagine is that it makes it
easier to compile the file on the command line using mlton instead of gcc.