[MLton] x86_64 bootstrap instructions?

Matthew Fluet fluet at cs.cornell.edu
Fri Oct 27 13:35:39 PDT 2006


> I've been trying to self-compile mlton on Linux/AMD64, but I haven't yet
> managed to succeed. I'm using the on-20050822-x86_64-branch code, and
> I've tried the following:
>
> - installed 32-bit libgmp
> - installed 32-bit mlton i386 binaries; verified that mlton seems to
> superficially work

You should verify that mlton more than superficially works.  Try compiling 
some small example programs.

> - I ran `linux32 make runtime` from the toplevel of the SVN tree, but it
> errored out:

You shouldn't need linux32.  The sources "know" about amd64/x86_64 as an 
architecture; they just target the 32bit subset.

> cd gen && ./gen-types
> rm -f gen/gen-types
> rm -f c-types.h ml-types.h
> cp gen/c-types.h c-types.h
> cp gen/ml-types.h ml-types.h
> mlton -output gen/gen-basis-ffi gen/gen-basis-ffi.sml
> /tmp/cciVV3uL.s: Assembler messages:
> /tmp/cciVV3uL.s:17: Error: `pusha' is not supported in 64-bit mode
> /tmp/cciVV3uL.s:25: Error: `popa' is not supported in 64-bit mode

Right; this is because mlton thinks that it running on i386, so calls gcc 
without the -m32 flags.  But, gcc thinks that it is running on amd64, so 
it reports an error for unsupported instructions.

I think that there are two ways around this:
  1) edit "/usr/lib/mlton/target-map", replacing "i386" with "amd64"
or
  2) edit "/usr/bin/mlton", duplicating each "-target-??-opt amd64 ???" 
argument as a "-target-??-opt x86 ???" argument, and deleting the 
existing "-target-cc-opt x86 ..." argument.

I beleive that either of these will give you a "working" i386 compiler on 
an amd64 machine, where by "working" means that the compiler will call gcc 
with the right flags to produce 32bit executables.

> (Running just "make runtime" yielded a different error earlier in the
> compilation process:
>
> cd gdtoa &&                                     \
>                gcc -std=gnu99 -I. -Iplatform  -m32 -mtune=opteron -O2
> -fomit-frame-pointer  -pedantic -Wall  -Wextra -Wformat=2
> -Wno-format-nonliteral -Wuninitialized  -Winit-self  -Wstrict-aliasing=2
> -Wfloat-equal  -Wundef -Wshadow  -Wpointer-arith  -Wbad-function-cast
> -Wcast-qual -Wcast-align  -Wwrite-strings -Waggregate-return
> -Wstrict-prototypes  -Wold-style-definition -Wmissing-prototypes
> -Wmissing-declarations -Wmissing-field-initializers -Wmissing-noreturn
> -Wmissing-format-attribute -Wredundant-decls  -Wnested-externs
> -Wlong-long  -Wdisabled-optimization  -Winline        \
>                        -w -O1 -c -DINFNAN_CHECK        \
>                        *.c
> In file included from /usr/include/features.h:346,
>                 from /usr/include/stdio.h:28,
>                 from arithchk.c:27:
> /usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or
> directory

That's not a problem with MLton.  I would guess that you haven't installed 
some lib32 devel packages.



More information about the MLton mailing list