[MLton] compile mlton using SML/NJ

Stephen Weeks sweeks at sweeks.com
Sun Oct 8 11:26:40 PDT 2006


> I'm trying to build the latest sources on an Intel Mac using SML/NJ.
> When I do a "make nj-mlton", I get the following errors
...
> /Users/jhr/Work/mlton/mlton/bin/upgrade-basis: line 31: mlton:  
> command not found
> Error: cannot upgrade basis because the compiler doesn't work

We use upgrade-basis.sml to work around basis library differences,
allowing a version of MLton written for a newer basis library to be
compiled by an older version of MLton.  The file isn't necessary when
bootstrapping for SML/NJ, but is listed in $(SOURCES), so the Makefile
is attempting to build it.  Building upgrade-basis.sml requires the
old version of MLton to be around so that the right stubs can be
built.

You can either 

    1. manually tweak sources to remove $(UP) until you're finished
       building MLton with SML/NJ and have a working MLton.
or  2. build upgrade-basis.sml on some other machine with a working
       MLton and copy it to your Intel Mac.
or  3. Use the upgrade-basis.sml that I just built, appended below.
       Note, this was built with a very recent version of MLton.

--------------------------------------------------------------------------------

structure MLton = 
   struct
      open MLton

      structure Platform =
         struct
            fun peek (l, f) = List.find f l
            fun omap (opt, f) = Option.map f opt
            val toLower = String.translate (str o Char.toLower)

            structure Arch =
               struct
                  datatype t = Alpha | AMD64 | ARM | HPPA | IA64 | m68k |
                               MIPS | PowerPC | S390 | Sparc | X86

                  val all = [(Alpha, "Alpha"),
                             (AMD64, "AMD64"),
                             (ARM, "ARM"),
                             (HPPA, "HPPA"),
                             (IA64, "IA64"),
                             (m68k, "m68k"),
                             (MIPS, "MIPS"),
                             (PowerPC, "PowerPC"), 
                             (S390, "S390"),
                             (Sparc, "Sparc"), 
                             (X86, "X86")]

                  fun fromString s =
                     let
                        val s = toLower s
                     in
                        omap (peek (all, fn (_, s') => s = toLower s'), #1)
                     end

                  val host = X86

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

            structure OS =
               struct
                  datatype t = AIX | Cygwin | Darwin | FreeBSD | HPUX | Linux
                             | MinGW | NetBSD | OpenBSD | Solaris

                  val all = [(AIX, "AIX"),
                             (Cygwin, "Cygwin"),
                             (Darwin, "Darwin"),
                             (FreeBSD, "FreeBSD"),
     (HPUX, "HPUX"),
                             (Linux, "Linux"),
                             (MinGW, "MinGW"),
                             (NetBSD, "NetBSD"),
                             (OpenBSD, "OpenBSD"),
                             (Solaris, "Solaris")]

                  fun fromString s =
                     let
                        val s = toLower s
                     in
                        omap (peek (all, fn (_, s') => s = toLower s'), #1)
                     end

                  val host = Linux

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




More information about the MLton mailing list