Building the 68000 cross compiler

This describes the process to build the binaries required to cross assemble and cross compile for the Outrun hardware. In fact, this applies to most if not all 68000-based platforms. We use the m68k-elf target, although none of the elf features are used. m68k-coff is no longer supported (it was up to binutils 2.16). It's a fairly long and tedious process, but for the sake of completeness I've documented the steps required.

Note: This page has been superseeded with a semi-automatic build script that will do all of the building for you without human interaction. This page can still be used for reference or for doing everything by hand.

Installing MinGW


First, we'll need something to compile binutils and GCC with. I've chosen MinGW as its output binaries have less dependencies than those produced by Cygwin. Download the installer from, run it and click Install. Leave the installation directory at c:\mingw (or change it, it doesn't really matter). For convenience, make sure 'install the graphical user interface' is selected and click 'continue'. Wait for the download and click 'continue' again.

The MinGW Installation Manager will start. Pick the following packages from 'Basic Setup':

And from 'MinGW Libraries' pick the following (needed for the C++ compiler):

Select 'Update Catalogue' from the Installation menu, click 'Review changes' and 'Apply'. Download will start and packages will be installed. You can always restart the installation manager later if you need additional packages.

Once complete, click 'Close' twice. Now navigate to the MSYS installation folder (c:\mingw\msys\1.0).

If your Windows user name contains spaces or other non 7-bit ASCII characters, edit msys.bat and add the following line at the top: SET USERNAME=SomeUser

Now start msys.bat and make sure you have sufficient user privileges or the thing may just hang. In the prompt, type: /postinstall/ Type 'y' twice, and enter 'c:/mingw' for the MinGW installation directory.

Just to test whether GCC is working, you can enter: gcc --version

In the odd case that you get a popup asking to insert a disk in a removable drive E: or I:, this is some sort of quirk of the MinGW prebuilt GCC binaries - at least at version 4.8.1-4/2013072200. The easiest way around that is to either insert some disk or change its drive letter.

Building Binutils (2.24)


The first prerequisite we'll need for cross-building anything is binutils, consisting of the GNU assembler (gas), the GNU linker (ld) and some other tools for object/library/executable manipulation. The latest version can be found at, we'll use binutils-2.24.

Download by clicking on the link, and move the .tar.bz2 file to your MSYS home directory, which is located in c:\mingw\msys\1.0\home\<username>\. Create a destination folder for the binaries you'll be using ultimately, for example c:\outrun\gcc\ (we'll use that below). Provided that you still have the MSYS shell open, unpack and compile binutils like this: tar jxvf binutils-2.24.tar.bz2
mkdir binutils-obj
cd binutils-obj
../binutils-2.24/configure --prefix=/c/outrun/gcc --target=m68k-elf
make install
cd ..
If all of this succeeds, you'll have a bunch of executables in c:\outrun\gcc\bin\, and together with a linker script, this should be enough to build the bootloader ROM images.

Building GCC (4.9.0)


Download the GCC 4.9.0 archive above, and copy the archive to the MSYS home folder. Unpack the contents: tar jxvf gcc-4.9.0.tar.bz2

Additional requirements for the C++ compiler and standard libs (do this before running ./configure):

If you want to also build the C++ compiler during this process, download the two archives above and unpack and move them into the GCC source tree. When building GCC, the ISL and CLooG libraries will automatically be compiled as well. tar jxvf isl-0.12.2.tar.bz2
mv isl-0.12.2 ./gcc-4.9.0/isl
tar xvf cloog-0.18.1.tar.gz
mv cloog-0.18.1 ./gcc-4.9.0/cloog

Now compile GCC itself. If you want to build the C++ compiler as well, change the --enable-languages flag into '--enable-languages=c,c++'. This does not build libstdc++-v3 yet, we'll have to wait until after having built newlib. mkdir gcc-obj
cd gcc-obj
../gcc-4.9.0/configure --prefix=/c/outrun/gcc --target=m68k-elf --enable-languages=c --with-newlib --disable-libmudflap --disable-libssp --disable-libgomp --disable-libstdcxx-pch --disable-threads --disable-nls --disable-libquadmath --with-gnu-as --with-gnu-ld --without-headers
make all-gcc
make install-gcc
cd ..
After this has completed - which will take a very long time - copy the following files from the c:\mingw\bin folder into c:\outrun\gcc\bin:

At this point, if you've endured the wait, you'll have a functional 68000 assembler and C compiler (and C++ compiler if you enabled it). All you'll need from here is a linker script and some startup code to build some basic executable.

For convenience, you can add c:\outrun\gcc\bin to your Windows %PATH% variable, either in the user settings (Computer → Properties → Advanced system settings → Advanced → Environment variables), or in a batch file you'll be using later on to set up your build environment.

Next up are some additional steps to build C (and C++) standard libraries for the 68000 platform.

Before continuing, make sure you restart the MinGW shell (MSYS) with the new %PATH% environment variable applied. Alternatively, you can temporarily add this to the MSYS environment through: export PATH=$PATH:/c/outrun/gcc/bin

Building Newlib (2.1.0)


Newlib is a C runtime library targeted for embedded platforms. This contains the usual basics such as fopen, malloc, printf and memcpy, as well as basic initialization and startup code you may choose to use (crt0.o).

In this configuration, the floating point support for functions like printf/sprintf has been stripped out as it'd pull in the fairly large software floating point emulation, even when not used in the format string.

System calls are also disabled, so we can provide our own later on instead of relying on dummy implementations. The most notable one is probably _sbrk, needed for anything that wants to use heap memory (i.e. malloc), so that one will need a (fairly straightforward) implementation.

And finally, multithreading and elaborate shutdown have been disabled, as our Outrun hardware doesn't really have an OS to begin with. Best scenario, it'll hang and automatically reboot due to the watchdog circuit timing out.

Download the archive above, move it into your MSYS home folder and unpack: tar xvf newlib-2.1.0.tar.gz
Should one compile newlib as-is - even though we're ultimately not using the implementations - one would run into two mismatching return types that would lead to compiler errors (and a failed build) in libgloss. So, before compiling, make sure to replace the following lines:

In newlib-2.1.0/libgloss/m68k/io-read.c: ssize_t read (int fd, void *buf, size_t count)
_READ_WRITE_RETURN_TYPE read (int fd, void *buf, size_t count)
In newlib-2.1.0/libgloss/m68k/io-write.c: ssize_t write (int fd, const void *buf, size_t count)
_READ_WRITE_RETURN_TYPE write (int fd, const void *buf, size_t count)
Afterwards, compile the library as follows: mkdir newlib-obj
cd newlib-obj
../newlib-2.1.0/configure --prefix=/c/outrun/gcc --target=m68k-elf --disable-newlib-multithread --disable-newlib-io-float --enable-lite-exit --disable-newlib-supplied-syscalls
make install
cd ..
Now you'll be able to use basic C library functionality that you're used to, with the side note that syscalls might have to be implemented along the way. If you're expecting fopen() to work, you'll need to provide the underlying infrastructure.

Building libgcc and libstdc++-v3

As we now have a functional C cross compiler set up, it's now also possible to build the C++ standard library that comes with GCC. Not that it's recommended to use many of it's features due to the quite limited amount of RAM and even ROM that is supported on our target system, but for completeness, libgcc and libstdc++ can be built like this:

cd gcc-obj
make all-target-libgcc all-target-libstdc++-v3
make install-target-libgcc install-target-libstdc++-v3
cd ..

This should complete the set; a cross-assembler, C and C++ compilers, linker, and standard C and C++ libraries. Provided that everything succeeded, you'll only need the destination folder you used (through --prefix), and you can throw away the temporary folders in the MSYS home directory.