[MLton] compiling mlton on latest mingw
Bernard Berthomieu <[email protected]> Mon, 22 Dec 2014 17:25:31 +0100
| Newsgroups | gmane.comp.lang.ml.mlton.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello,
(long)
Like others did (https://github.com/MLton/mlton/issues/61), I observed
that mlton 2014 could not be successfully built in recent mingw environments
from the mlton git sources and the available mlton-20100608 distribution
(http://mlton.org/Release20100608): mlton-compile.exe is built but
segfaults.
On the other hand, mlton 2014 can be built in the mingw environment
coming with mlton-20100608 (carrying gcc-4.4.3). It works just fine, but
gcc-4.4.3 is clearly obsolete.
It appears that the segfault results from incompatibility between objects
created with the current mingw (mlton-compile.exe in our case) and the
static libraries captured by mlton-20100608 (the *.a files in mlton/lib).
The compatibility issues are discussed in:
http://www.mingw.org/wiki/Interoperability_of_Libraries_Created_by_Different_Compiler_Brands
where it is explained that one should avoid linking together an object file
created in some mingw environment with static libraries created in
another.
mlton 2014 can be built actually, but in three steps:
1. compile mlton-2014 in the mingw environment coming with mlton-20100608:
make all-no-docs -r
You will have to hack file ./mlton/front-end/Makefile since it makes use of
flag -i for sed, which was not supported by the version of sed shipped
with mlton-20100608. Make is very slow on mingw, -r may help.
In spite of some gcc warnings, the mlton compiler created in ./build works.
Save it as /c/build-1 (say):
mv build build-1
tar cf - build-1 | (cd /c; tar xf -)
/c/build-1 is entirely created with gcc 4.4.3.
2. In your up to date mingw environment, compile mlton 2014 using
the available gcc (mine is 4.9.2) and the mlton compiler produced
at step 1:
compile and install libgmp
compile and install dlfcn, or just pick dlfcn.h from the mlton sources
and copy it into the include directory of mingw already containing
stdio.h.
export PATH=/c/build-1/bin:$PATH
make clean -r
make all-no-docs -r
The build eventually fails, but it fails after the *.a mlton
libraries have been built. On failure, Save ./build as /c/built-2,
then replace its get mlton-compile.exe by that in /c/built-1,
and get the constants file from /c/built-1 too:
mv build build-2
tar cf - build-2 | (cd /c; tar xf -)
cp /c/build-1/lib/mlton-compile.exe /c/build-2/lib
cp /c/build-1/lib/target/self/constants /c/build-2/lib/targets/self
/c/built-2 is a working mlton compiler but with mlton-compile.exe
built by gcc-4.4.3 and the *.a libraries compiled by gcc-4.9.2;
3. Compile mlton 2014 using the mlton compiler in /c/build-2:
export PATH=/c/built-2/bin:$PATH
make clean -r
make all-no-docs -r
This ends up with :-) :
Build of MLton succeeded.
./build now holds a working mlton 2014 compiler with nothing left
from mlton-20100608 or gcc-4.4.3. If one is interested, I put an
archive of my ./build on page www.laas.fr/tina/software
I did not check the regressions yet.
I have now to build the 64 bit version :-( . Since mlton-20100608 is a
cross-compiler, it should be possible to produce a 64 bit compiler
at step 1, but I did not try yet.
Bernard.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net