[MLton] upgrade-basis hangs

Tom Murphy tom7@cs.cmu.edu
Sun, 11 Jan 2004 20:28:53 -0500 (EST)


OK, I stuck set -x at the top, and here's what I get (below).

This is on linux (an old redhat), bash 1.14.7(1). MLton is 20020410.

If I change the script to execute bash2 (version 2.03.4(1)), then it
seems to succeed. I'm guessing that the semantics of the | feature
... "`cat`" idiom changed between bash 1 and 2.

Unfortunately, even though upgrade-basis seems to succeed, mlton fails to
compile with errors from the generated upgrade-basis.sml.

set -x with bash 1:
[root@spacebar mlton]# /usr/src/mlton-20040106/bin/upgrade-basis
"/usr/src/mlton-20040106/build/bin:/usr/src/mlton-20040106/build/bin:/usr/src/mlton-20040106/build/bin:/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin"
>upgrade-basis.sml
+ /usr/src/mlton-20040106/bin/upgrade-basis
/usr/src/mlton-20040106/build/bin:/usr/src/mlton-20040106/build/bin:/usr/src/mlton-20040106/build/bin:/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
+ set -e
++ basename /usr/src/mlton-20040106/bin/upgrade-basis
+ name=upgrade-basis
+
PATH=/usr/src/mlton-20040106/build/bin:/usr/src/mlton-20040106/build/bin:/usr/src/mlton-20040106/build/bin:/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
+ tmp=31386.sml
+ feature fun f x : string option = TextIO.inputLine x
structure TextIO =
   struct
      open TextIO

      fun inputLine ins =
         case TextIO.inputLine ins of
            "" => NONE
          | s => SOME s
   end
+ feature=fun f x : string option = TextIO.inputLine x
+ sml=
structure TextIO =
   struct
      open TextIO

      fun inputLine ins =
         case TextIO.inputLine ins of
            "" => NONE
          | s => SOME s
   end
+ echo fun f x : string option = TextIO.inputLine x
+ mlton 31386.sml
+ echo
structure TextIO =
   struct
      open TextIO

      fun inputLine ins =
         case TextIO.inputLine ins of
            "" => NONE
          | s => SOME s
   end
+ feature fun f x : string option = OS.FileSys.readDir x
structure OS =
   struct
      open OS
      structure FileSys =
         struct
            open FileSys
            fun readDir d =
               case FileSys.readDir d of
                  "" => NONE
                | s => SOME s
         end
   end
+ feature=fun f x : string option = OS.FileSys.readDir x
+ sml=
structure OS =
   struct
      open OS
      structure FileSys =
         struct
            open FileSys
            fun readDir d =
               case FileSys.readDir d of
                  "" => NONE
                | s => SOME s
         end
   end
+ echo fun f x : string option = OS.FileSys.readDir x
+ mlton 31386.sml
+ echo
structure OS =
   struct
      open OS
      structure FileSys =
         struct
            open FileSys
            fun readDir d =
               case FileSys.readDir d of
                  "" => NONE
                | s => SOME s
         end
   end
+ feature val _ = IntInf.~>>
structure IntInf =
   struct
      open IntInf

      val ~>> : int * Word.word -> int =
         fn _ => raise Fail "IntInf.~>>"
   end
+ feature=val _ = IntInf.~>>
+ sml=
structure IntInf =
   struct
      open IntInf

      val ~>> : int * Word.word -> int =
         fn _ => raise Fail "IntInf.~>>"
   end
+ echo val _ = IntInf.~>>
+ mlton 31386.sml
+ echo
structure IntInf =
   struct
      open IntInf

      val ~>> : int * Word.word -> int =
         fn _ => raise Fail "IntInf.~>>"
   end
+ cat
++ cat


When using bash 2, I get these errors after upgrade-basis completes:

make[3]: Leaving directory `/usr/src/mlton-20040106/mlton'
Compiling mlton (takes a while)
mlton @MLton ram-slop 0.7 gc-summary  -- -host self -v -o mlton-compile
mlton-stubs.cm
MLton starting
   Compile SML starting
      pre codegen starting
upgrade-basis.sml:43.41-43.54 Error: unbound tycon Platform.arch
upgrade-basis.sml:45.30-45.43 Error: unbound variable Platform.arch
upgrade-basis.sml:47.31-47.36 Error: unbound variable Sparc
upgrade-basis.sml:47.49-47.52 Error: unbound variable X86
upgrade-basis.sml:56.41-56.52 Error: unbound tycon Platform.os
upgrade-basis.sml:58.30-58.41 Error: unbound variable Platform.os
upgrade-basis.sml:61.31-61.38 Error: unbound variable FreeBSD

Here's what the upgrade-basis.sml file has:

structure TextIO =
   struct
      open TextIO

      fun inputLine ins =
         case TextIO.inputLine ins of
            "" => NONE
          | s => SOME s
   end

structure OS =
   struct
      open OS
      structure FileSys =
         struct
            open FileSys
            fun readDir d =
               case FileSys.readDir d of
                  "" => NONE
                | s => SOME s
         end
   end

structure IntInf =
   struct
      open IntInf

      val ~>> : int * Word.word -> int =
         fn _ => raise Fail "IntInf.~>>"
   end
structure MLton =
   struct
      open MLton

      structure Platform =
         struct
            fun peek (l, f) = List.find f l
            fun omap (opt, f) = Option.map f opt

            structure Arch =
               struct
                  datatype t = datatype Platform.arch

                  val host = Platform.arch

                  val all = [(Sparc, "sparc"), (X86, "x86")]

                  fun fromString s = omap (peek (all, fn (_, s') => s =
s'), #1)

                  fun toString a = #2 (valOf (peek (all, fn (a', _) => a =
a')))
               end

            structure OS =
               struct
                  datatype t = datatype Platform.os

                  val host = Platform.os

                  val all = [(Cygwin, "cygwin"),
                             (FreeBSD, "freebsd"),
                             (Linux, "linux")]

                  fun fromString s = omap (peek (all, fn (_, s') => s =
s'), #1)

                  fun toString a = #2 (valOf (peek (all, fn (a', _) => a =
a')))
               end
         end
   end




I can confirm that my version of mlton doesn't have the Platform.os type.


Is this version of mlton too old to bootstrap from?


Thanks for the help,

   Tom


>
> > I'm trying to compile the 20040106 beta, but the upgrade-basis script
> > hangs (strace indicates it's reading from stdin). I can't install binaries
> > because I have an old libc and no upgrade path.
> >
> > What might be going wrong? I don't mind getting into the scripts, but I
> > don't have any clue what it's trying to do or why it'd be reading from
> > stdin.
>
> I'm not sure what's going on.  Could you run the script with set -x
> and show us how far it gets?  The script tests the MLton that is being
> used for bootstrapping to see how it handles various basis library
> things, and then adds appropriate stubs to make all MLton's look
> uniform (enough for bootstrapping, anyway).
>
> Also, if you can let us know the version of MLton you're bootstrapping
> from, that might help.
>