[MLton] mingwows

Stephen Weeks MLton@mlton.org
Thu, 10 Nov 2005 11:48:25 -0800


> > I'm wondering what advantage the bat script has over the standard
> > MLton script that can be run in MSYS?  Would there really be people
> > who have MinGW but not MSYS, 
> 
> Absolutely. Me.

My question was not clear enough.  By "people" I meant typical windows
users that want to run MLton on their Windows machine and use it to
generate executables that run on Windows.  It is these people that we
are trying to target with the MLton Cygwin and MinGW binary packages.
For Cygwin MLton, the packaging is pretty clear, because Cygwin comes
with both the libraries and shell.  For MinGW MLton, it seems to me
that running MLton under MSYS is the right analogue.  But if there is
another common way (such as CMD.EXE) and it is easy to support in the
package, I would like to do so.

> Under Cygwin .. which is the preferred way of using MinGW, you just
> say:
>
> gcc -mno-cygwin ...

I was not aware that this was the preferred way.  I have heard others
say that there are problems with -mno-cygwin and it is better to run
the MinGW gcc.  In any case, it is a reasonable mode of operation to
run MLton under Cygwin and generate MinGW executables.  One need only
install the appropriate cross-compiler support in lib/mlton and run
mlton with flags something like the following.

  -cc-opt -mno-cygwin 
  -link-opt -mno-cygwin
  -target i386-pc-mingw 

(Perhaps the -mno-cygwin is only needed when linking?  I don't know.)
Once somebody actually succeeds in doing this, it would be great to
add a note to http://mlton.org/RunningOn{Cygwin,MinGW}.

All that being said, the MLton MinGW binary package is targeting a
different set of Windows users: those who don't want to install or use
Cygwin.

> I think you're misunderstanding the situation: MinGW is just
> gcc. There's no environment.

I understand that MinGW is not an environment.  What I am trying to
learn is the environment(s) under which a typical Windows user uses
MinGW (other than Cygwin, since we already have a MLton Cygwin
package).

> I have MinGW on BOTH Cygwin AND Linux! I can generate Win32
> executable both ways -- but I don't use MSYS.

Sure.  Cross compilation is fine.  What I want to do is to make it
easy for someone who wants to use MLton on Windows to generate MinGW
executables.  Obviously they must have installed MinGW.  I don't see
any reason to force them to install Cygwin (or Linux :-).

> The point is -- there is no MSYS and no issue of using a DOS shell
> either. You execute the binaries the same way as under Windows
> because they ARE native Windows binaries.

I don't understand this point.  The MLton executable needs a driver
program to run.  This driver program is currently a script.  So, a
Windows user that wants to run MLton needs to run a driver script.
MSYS is one way to run the driver.  CMD.EXE with the .bat is another.

> BTW: the MinGW version of Ocaml is built with, and requires,
> Cygwin's version of gcc/mingw, INRIA claims the MSYS version is
> broken (something about not accepting long command lines ..)

Perhaps that problem has been fixed.  MLton feeds long command lines
(thousands of characters) to gcc and I've not seen a problem.

> BTW2: For Felix, I supply *.bat scripts for MSVC++ builds, and bash
> for Cygwin or MinGW builds. 

Good, so it probably makes sense for MLton to supply a .bat.

> However the way to RUN the built executables is with Windows batch
> files.

I don't understand why the generated executables need a batch file at
all.  But that may be getting off topic.

> You should not install in C:\MinGW, you must NOT mention any
> specific drive letter or top level directory: that would never work
> on a networked system.

The MLton MinGW binary package (tgz) looks like

  mingw/
  mingw/bin/
  mingw/bin/mllex.exe
  mingw/bin/mlnlffigen.exe
  mingw/bin/mlprof.exe
  mingw/bin/mlton
  mingw/bin/mlyacc.exe
  mingw/lib/
  mingw/lib/mlton/
  mingw/lib/mlton/include/
  ...

> I'm under Linux at the moment, so I can't check the
> details, but the correct place to install is in
> something like:
> 
> %Program Root%\mlton
> 
> or something; that will be filled in automatically by the
> Windows shell from the registry/system paths, with the
> correct place to put packages, usually, but not always,
> this will be
> 
> C:\Program Files
> 
> Your PATH should be extended the same way.
> 
> All this stuff is driven by installing bat scripts ..
> in %Windows% which is usually C:\Windows .. but again,
> not always. That directory is ALWAYS on the PATH :)
> 
> With some fiddling, this means you can run everything
> without setting up any environment (the bat script
> for each command does that each time).

This is all beyond me.  The MLton MinGW package is just a tgz.  There
is no install script.