Latest changes:
make install-info
is necessary to get all
info pages installed.
This setup has been tested on a i686-pc-linux-gnu (GNU/Linux) and a x86_64-unknown-linux-gnu system, but there should be no problems for other UNIX-type systems, possibly including Cygwin and MinGW systems, although you may need to install some GNU development tool programs like bison and use GNU make instead of your existing make program. An existing installation of GCC is required, for compiling everything from source.
How to install the GNU compiler tools, so you can compile and run C and C++ programs for MMIX:
$PATH
the mmix
simulator from the
MMIXware tools. Do not use a version marked earlier than "13
January 2002". I have had no problem with the version marked "15 June
2002"; any later release probably works too.
You need to have the programs
ctangle
and cweave
from the cweb
package installed, before you compile the MMIXware tools.
Note that the mmixal
assembler is not used by the GNU
tools. Actually, the mmix
simulator isn't used either
except when running the test-suite but without it, the output of the
compiler tools isn't very usable.
Do one of the following. Unless you want to help with development of GCC, binutils or newlib, please use the first alternative and official, pristine, released sources.
Caution: do not ever use relative paths (../dir), always use absolute paths (/path/to/dir).
With released versions of gcc, binutils and newlib:
Using a GNU mirror, download a recent version of gcc. The most recent version verified to work with these instructions is M=4.3.5. Download either the whole tar-ball, gcc-M.tar.bz2 or the smaller tar-ball called gcc-core-M.tar.bz2 (if you intend to use only C; not C++ or Objective C).
Similarly, download a recent version of the GNU binutils. The most recent verified version is N=2.21.
From the newlib FTP directory, download a recent version of newlib. The most recent version verified is O=1.19.0.
On a disk with enough free space (about 1 GiB for the
build directory and and sources, about 200 MeB for the
installation), do tar -xjf binutils-N.tar.bz2
Configure the GNU binutils in an empty directory
(mkdir emptydir
; cd emptydir
):
/path/to/binutils-N/configure --target=mmix --prefix=/mmix/install/directory
Build and install binutils: make all
then: make install
Now, we'll create a unified directory with both gcc and
newlib, so we can build and install both at the same time,
instead of a more complicated, staged, procedure (they are
co-dependent). First, unpack newlib:
tar -xzf newlib-O.tar.gz
Rename the directory where tar
unpacked newlib:
mv newlib-O gcc-M
Do: tar -xjf gcc-M.tar.bz2
. This will
unpack the gcc files over the previously unpacked newlib
files, replacing newlib files with gcc files when same names
are present. Many files are common, but gcc releases are
usually newer and are more dependent than newlib, on having
its "own" version of those common files.
Now, like with binutils, create a (new) empty directory
(mkdir emptydir
; cd emptydir
) and
from there configure the gcc+newlib files, making sure the
programs in the GNU binutils mmix installation are seen.
You may of course drop the "env PATH=..." parts
below if /mmix/install/directory/bin
is already
in your $PATH
. Similarly if you omit the
--prefix
option, and the default program
installation directory, /usr/local/bin
, is in
your $PATH
:
env PATH=/mmix/install/directory/bin:$PATH
/path/to/gcc-N/configure --target=mmix --prefix=/mmix/install/directory
Build and install gcc+newlib, again with access to just-installed binutils:
env PATH=/mmix/install/directory/bin:$PATH make
all
, then env
PATH=/mmix/install/directory/bin:$PATH make
install
Assuming there were no errors, you now have a working
gcc-N release, compiled to generate code for mmix.
Don't forget to add /mmix/install/directory/bin
to your $PATH
variable. You can now compile
and run a "hello, world" program:
$ cat >hello.c <<EOF #include <stdio.h> #include <stdlib.h> int main (int argc, char **argv) { printf ("hello, %s\n", argc > 1 ? argv[1] : "world"); exit (0); } EOF $ mmix-gcc -o mmixhello hello.c $ mmix mmixhello "from the mmixware simulator" hello, from the mmixware simulator
The usual gcc options apply. If you prefer C++, just do the
equivalent mmix-g++
command for the equivalent C++
version of hello-world, of course. Further information is
installed in /mmix/install/directory/man
and in
/mmix/install/directory/info
in the GNU info
format.
Or, using snapshots, download some snapshot of binutils and a gcc snapshot (any after 2001-11-03), mixing and matching together with the newlib CVS sources, or with the released tar-balls mentioned above. Proceed as with the instructions above for building from official releases. N.B.: these snapshots may or may not contain all required generated files as the releases do; you may have to install e.g. the bison or makeinfo programs.
Or, use "live" sources and follow the GCC
simulator test how-to instructions to create and build in a
combined tree. You may exclude the "gdb" component mentioned at
that page. Don't forget to make install
.
If you encounter problems of any kind, during installation or use (not strictly solved by debugging your program :-) please report them using the respective bug-tracking tool for GCC or Binutils and Newlib. Put hp at (either of, corresponding to the tool domain) gcc.gnu.org (or) sourceware.org in the CC field, to get my attention.
If you want to help with development of GCC and the other GNU tools for MMIX,
install DejaGNU, of at least version 1.4.4 (see GNU mirrors). With
that in place, the simulator test how-to
instructions with
RUNTESTFLAGS=--target_board=mmixware-sim
apply for
testing changes. Be sure to follow mailing lists for GCC
development and please contribute improvements as per GCC contribution
instructions. Similarly for MMIX binutils and
newlib improvements.