Vincent Rivière's m68k-atari-mint cross-tools

This page is dedicated to the programmers who want to:

You will find here gcc, g++, as, ld, and other tools configured to produce executables for the Atari ST. It means that you can use all the latest C++ features, such as templates, exceptions, STL, as well as inline assembly, to build software which will run on your old Atari ST.

The original sources are provided, as well as the patches and the build scripts. It would be easy to recompile them on any operating system already supporting the GNU tools.
Feel free to redistribute, recompile, and improve the packages, with respect to their own licenses.


You enjoy this software?
Please consider making a donation.

Quickstart for Windows

  1. Install Cygwin 32-bit. This will provide you a full UNIX-like environment necessary for running the GNU tools.
  2. Install the following packages, using the Cygwin setup program: libmpc3.
  3. Download and install cross-mint-cygwin-20160320-setup.exe.
  4. Now you can use any tool prefixed by m68k-atari-mint-, such as m68k-atari-mint-gcc, m68k-atari-mint-g++, and even read the man pages.

Everything is installed in /opt/cross-mint.
If you want to completely uninstall the tools, you just have to remove that directory.

Other operating systems

Individual packages

These packages can only be useful for advanced users.

Component Version Packages
binutils 2.26
GitHub repository: freemint/m68k-atari-mint-binutils-gdb
Original sources: binutils-2.26.tar.bz2 (official and faster link)
MiNT patch: binutils-2.26-mint-20160320.patch.bz2
Build script: binutils-2.26-mint-20160320-bin-cygwin-howto.txt
Cygwin Package: binutils-2.26-mint-20160320-bin-cygwin-20160320.tar.bz2
MiNTBin CVS-20110527
Original sources: mintbin-CVS-20110527.tar.gz
Build script: mintbin-CVS-20110527-bin-cygwin-howto.txt
Cygwin Package: mintbin-CVS-20110527-bin-cygwin-20110527.tar.bz2
GCC 4.6.4
GitHub repository: freemint/m68k-atari-mint-gcc
Original sources: gcc-4.6.4.tar.bz2 (official and faster link)
MiNT patch: gcc-4.6.4-mint-20130415.patch.bz2
Build script: gcc-4.6.4-mint-20130415-bin-cygwin-howto.txt
Cygwin Package: gcc-4.6.4-mint-20130415-bin-cygwin-20131103.tar.bz2
MiNTLib CVS-20160320
Original sources: mintlib-CVS-20160320.tar.gz
Build script: mintlib-CVS-20160320-bin-cygwin-howto.txt
Cygwin Package: mintlib-CVS-20160320-bin-cygwin-20160320.tar.bz2
PML 2.03
Original sources: pml-2.03.tar.bz2
MiNT patch: pml-2.03-mint-20110207.patch.bz2
Build script: pml-2.03-mint-20110207-bin-cygwin-howto.txt
Cygwin Package: pml-2.03-mint-20110207-bin-cygwin-20131103.tar.bz2
GEMlib CVS-20130415
Original sources: gemlib-CVS-20130415.tar.bz2
Build script: gemlib-CVS-20130415-bin-cygwin-howto.txt
Cygwin Package: gemlib-CVS-20130415-bin-cygwin-20131104.tar.bz2
GDB 5.1
GitHub repository: freemint/m68k-atari-mint-binutils-gdb
Original sources: gdb-5.1.tar.gz
MiNT patch: gdb-5.1-mint-20081102.patch.bz2
Cygwin build script: gdb-5.1-mint-20081102-bin-cygwin-howto.txt
Cygwin Package: gdb-5.1-mint-20081102-bin-cygwin-20100124.tar.bz2
MiNT build script: gdb-5.1-mint-20081102-bin-mint-howto.txt
MiNT Package: gdb-5.1-mint-20081102-bin-mint-20100124.tar.bz2
CFLIB CVS-20130415
Original sources: cflib-CVS-20130415.tar.bz2
Build script: cflib-CVS-20130415-bin-cygwin-howto.txt
Cygwin Package: cflib-CVS-20130415-bin-cygwin-20131104.tar.bz2
LDG SVN-20131104
Original sources: ldg-SVN-20131104.tar.bz2
Build script: ldg-SVN-20131104-bin-cygwin-howto.txt
Cygwin Package: ldg-SVN-20131104-bin-cygwin-20131104.tar.bz2
SDL 1.2-HG-20140906
Original sources: sdl-1.2-HG-20140906.tar.bz2
Build script: sdl-1.2-HG-20140906-bin-cygwin-howto.txt
Cygwin Package: sdl-1.2-HG-20140906-bin-cygwin-20140906.tar.bz2
Ncurses 5.9
Original sources: ncurses-5.9.tar.gz
Build script: ncurses-5.9-bin-cygwin-howto.txt
Cygwin Package: ncurses-5.9-bin-cygwin-20131104.tar.bz2
zlib 1.2.8
Original sources: zlib-1.2.8.tar.gz
Build script: zlib-1.2.8-bin-cygwin-howto.txt
Cygwin Package: zlib-1.2.8-bin-cygwin-20131105.tar.bz2
Readline 6.2
Original sources: readline-6.2.tar.gz
Build script: readline-6.2-bin-cygwin-howto.txt
Cygwin Package: readline-6.2-bin-cygwin-20131212.tar.bz2
OpenSSL 1.0.1e
Original sources: openssl-1.0.1e.tar.gz
MiNT patch: openssl-1.0.1e-mint-20131219.patch.bz2
Build script: openssl-1.0.1e-mint-20131219-bin-cygwin-howto.txt
Cygwin Package: openssl-1.0.1e-mint-20131219-bin-cygwin-20131219.tar.bz2
cygwin-setup 20160320
Sources: cross-mint-cygwin-20160320-setup-src.zip
Binary: cross-mint-cygwin-20160320-setup.exe

The following packages are required in order to build GCC 4.3.0 and higher.
Normally, you should use the official versions packaged with your operating system instead of rebuilding them.
These packages are not used anymore for compiling GCC on Cygwin. I let them here because they may be useful for building GCC on hosts where they are not officially supported.

Component Version Packages
GMP 4.3.1
Original sources: gmp-4.3.1.tar.bz2
Build script: gmp-4.3.1-bin-cygwin-howto.txt
MPFR 2.4.1
Original sources: mpfr-2.4.1.tar.bz2
Build script: mpfr-2.4.1-bin-cygwin-howto.txt

Packages history is available here.

More information

The original binutils patch was written by Guido Flohr.
Patrice Mandin has ported that patch to many versions of GCC and the binutils. You can find those versions and nice tutorials on his site.

I started to be interested in cross-compilation in 2002. I wanted to build software for the Atari ST from Windows, so I looked for it on the web. Fortunately, I found that a port of GCC was made for the MiNT project. I downloaded the patches, and ported them to the current versions. Later, I ported my patches to newer versions of GCC and the binutils. Every time, I spent a lot of time, for an incomplete result that I didn't share.

In 2007, I thought to all that wasted time. I decided to do the port once again, but this time with the aim of getting something fully usable, which I could share with other people. I found a few bugs in the binutils which were real problems for the MiNT target. Thanks to the binutils team (especially Nick Clifton - many thanks!), the bugs were fixed in the official sources, being a benefit for all other targets.

Please note that I'm not particularly interested in MiNT and the MiNTLib. I just want to be able to build programs for the plain old TOS. As far as I know, the MiNTLib is currently the only standard library supported by GCC for the Atari targets. It may not be a problem, because it is backwards compatible with TOS, but it produces too big executables.

Here is further information about the packages.

binutils

The binutils are a collection of low-level language tools.
The full documentation can be found here.

m68k-atari-mint-as is the assembler (later referred as gas)
It converts an assembler source file into a binary object file. Due to limitations in the current linker, the generated file format must be an a.out variant. The older patches used a MiNT-specific file format. Because there is nothing specific to MiNT in the object files, I decided to use the file format a.out-zero-big instead, which is a standard variant of a.out natively supported by the binutils.
Recent versions of gas accept the standard Motorola syntax, but the assembler directives are slightly different from Devpac's.
Note that gas produces sections of size multiple of 4. This allows to align data to a 4-byte boundary by using the .balign 4 directive. This is only useful for a 68020+ CPU in FastRAM, but useless for old 68000 targets, where 2 bytes may be wasted at the end of each .o file.
By default gas generates code for the 68020 (unlike GCC), and it tries to optimize the jump instructions when possible. When you use m68k-atari-mint-as directly, make sure to append the -m68000 command-line option to avoid the generation of instructions like bsr.l which would bomb out on a standard 68000.

m68k-atari-mint-ld is the linker.
It is able to combine several object files into one standard TOS executable.
Guido Flohr found an excellent trick: by adding an additional header of 228 bytes after the standard 28 byte header, he was able to make executables which can be treated either as a TOS executable (by the TOS and MiNT) or as a standard a.out executable (by other GNU utilities).
By default, the debug info is generated in STABS format. Standard DRI symbols can be generated by appending the option --traditional-format. Thus, you can see the generated symbols with your favorite debugger such as MonST !
If you don't want any debug symbol, just link with the -s option.

MiNTBin

MiNTBin has been written by Guido Flohr. It is a set of tools for manipulating the MiNT executables generated by ld. They are a complement to the binutils. The main tools are stack for setting the stack size of an executable, and flags for setting the header flags.

GCC

m68k-atari-mint-gcc is the C compiler.
m68k-atari-mint-g++ is the C++ compiler.
They just work. I only tested the C and C++ languages, but other languages may work, too.
If you want to generate DRI symbols in the final executable, append the option -Wl,--traditional-format to inform the linker.
I configured this version to generate 68000 code by default, and I enabled multilib. By default, sizeof(int) == 4, but if you compile with -mshort then sizeof(int) == 2 (unsupported by the current MiNTLib). Every object file and every library must be compiled with the same option ! You can also generate code for the 68020 and higher and for the FPU by using the -m68020-60 option. And you can generate code for ColdFire V4e processors by using the -mcpu=5475 option.
The full documentation can be found here.
GCC contains everything to compile C programs, except a standard library and a math library.

MiNTLib

MiNTLib is a standard C library. It allows to build software which runs on MiNT and TOS operating systems. Unlike other packages, I used the latest sources from the CVS repository instead of the latest official release.
I'm not particularly interested by MiNT, so I don't plan to make more work on the MiNTLib than necessary to compile it. The latest versions of the MiNTLib produces executables which are really too big, compared to the older versions of the MiNTLib or the Pure C.

PML

PML stands for Portable Math Library.
It works, but of course it is really slow on a 68000 without FPU.

GEMlib

The GEMlib allows to write graphical programs using GEM.
It is maintained by Arnaud Bercegeay, the official releases are available on the GEMlib's homepage. However, the latest sources are available on the SpareMiNT's CVS repository.

GDB

GDB is the GNU debugger. It allows to debug a MiNT executable, put breakpoints in the C or C++ sources, examine the variables, step trough code lines...

Two binary packages are provided:

Remote debugging allows a MiNT program to be run or a real Atari machine (or emulator), while the debugger runs on another machine. For example, you can run GDB on Cygwin for debugging a program running inside ARAnyM. The communication between the two machines is done using TCP/IP.

Quick HOWTO for remote debugging using Cygwin and ARAnyM:

  1. Let say that your ARAnyM IP address is 192.168.0.2, and you want to debug an executable named hello using the TCP port 4444. Any unused port between 1024 and 65535 can be used.
  2. Make sure TCP/IP works between Cygwin and ARAnyM (check with ping in both directions).
  3. Compile hello with debug information: m68k-atari-mint-gcc hello.c -o hello -g
  4. Keep the executable with debug information on Cygwin, and put a copy (or stripped copy) into ARAnyM (or better: use HOSTFS).
  5. On ARAnyM, run the command gdbserver :4444 hello
    gdbserver will start hello in suspended mode and will wait for incoming connections. No further action will be required on the ARAnyM side (except looking at the program output).
  6. On Cygwin, run the command m68k-atari-mint-gdb hello.
  7. At the (gdb) prompt, type target remote 192.168.0.2:4444
    On both sides, the message "Remote debuggin using..." will be displayed.
  8. On Cygwin, use gdb as usual. Put a breakpoing using b main. Then type cont (instead of run), because the remote process has already been started remotely.

Debugging can be more user-friendly !
Run m68k-atari-mint-gdb with the --tui option to enable full-screen source debugging.

You can even use the graphical debugger ddd for remote debugging MiNT programs.

  1. On Cygwin, install the ddd package.
  2. On ARAnyM, run gdbserver as described above.
  3. On Cygwin, start X-Window with the command startx.
  4. In the xterm window, type ddd --debugger m68k-atari-mint-gdb hello
  5. In the ddd command window, type the target remote... command.
  6. Use ddd as usual !

Important note: this release of gdb 5.1 is experimental, and suffers from severe issues:

CFLIB

CFLIB is Christian Felsch's GEM utility library. It provide advanced controls, such as check boxes, radio buttons, combo boxes... It also allows windowed dialogs.
BUG: On plain TOS, the CFLIB makes intensive usage of the GEM USERDEF feature. Due to bad GEM design, USERDEF callbacks are called in supervisor mode using the very small internal AES stack. Unfortunately, some GemLib functions such as v_gtext() needs an insane amout of stack (more than 2 KB). So some USERDEF callbacks quickly produces an AES internal stack overflow, and crashes all the system.
Concretely, due to this issue, programs using the CFLIB work fine on XaAES and TOS 4.04, but crashes on TOS 1.62 and EmuTOS.

LDG

LDG stands for Gem Dynamical Libraries. It allows you to use or build .ldg shared libraries. Everything is described on the LDG official website.

SDL

SDL is the Simple DirectMedia Layer library. It is a low-level and cross-platform library for building games or similar programs.
Thanks to Patrice Mandin, SDL is available on Atari platforms. SDL programs can run either in full screen or in a GEM window, depending on the SDL_VIDEODRIVER environment variable.

Ncurses

Ncurses is a library which allows building full-screen text mode programs, such as vim, less, or the GDB text UI.

zlib

zlib is a compression library implementing the Deflate algorithm, used by gzip and PKZIP.

Readline

Readline is a library to allow command line history and completion.

OpenSSL

OpenSSL is an SSL and cryptography library.

A sample program

$ cat hello.c
#include <stdio.h>

int main(int argc, char* argv[])
{
    puts("Hello, world !");

    return 0;
}

$ m68k-atari-mint-gcc hello.c -o hello.tos -O2 -Wl,--traditional-format
$ ls -l hello.tos
-rwxr-xr-x 1 vincent cygwin 80073 Jan  8 20:23 hello.tos

Note: The -Wl,--traditional-format option above is only useful when you want to use a classic Atari debugger like MonST2, as seen on the picture below. Do not use that option in general case.

I recommend the excellent emulator Steem Engine for testing your programs under Windows and Linux.

MonST 2

MiNT Software

As a proof of concept, I have compiled some popular free software for MiNT using this cross-compiler, and it works very well. This is due to the excellent compatibility provided by the FreeMiNT kernel and the MiNTLib. Some binaries may even run on plain TOS. If you want to test MiNT software, you can use the ARAnyM system emulator. The easiest way to begin is to use the AFROS distribution.

Conclusion

I have been able to compile several programs with these tools, from a simple "Hello, world !" to complex C++ programs using CppUnit. They are now mature enough to be shared, and maybe useful to someone else.

Feel free to send me your comments !

Vincent Rivière

Links

Patrice Mandin has made a lot of work for porting GCC and the binutils to the MiNT platform. His work is available here.

Olivier Landemarre has made its own port of GCC 4.2 to the the MiNT platform. He also has a great list of Atari-related stuff.

François Le Coat is the author of the ATARI Search Engine.

Thomas Huth is the author of the Hatari ST emulator. He has sucessfully recompiled this GCC port on Linux, on his PowerMac G4, and has successfully compiled EmuTOS with it !

Keith Scroggins has ported ScummVM to MiNT. Build instructions are available here. He has also made his own native port of GCC 4.0.1 several years before me, his work is available here.

Miro Kropáček has compiled this GCC port for the MiNT host. That means you can run the latest GCC natively on your Atari/MiNT computer, without cross-compilation ! He also made a nice Makefile for building all the toolchain. His work is available here.

Paweł Góralski has ported REminiscence to Falcon using this compiler. It is an interpreter for Delphine Software games, enabling to play Flashback on Falcon. He also maintains the Bus Error Wiki with a lot of programming tricks using these cross-tools.

Mark Duckworth has built an RPM package for native MiNT binutils, using the patch available on this page. He has compiled natively a lot of other RPM packages, his work is available here.

Dominique Béréziat has written a tutorial for cross-compiling GEM applications.

Philipp Donzé has built the binaries of these cross-tools for MacOS X (Intel and PowerPC supported). His binaries as well as installation instructions are available here.

Rolf Hemmerling has a nice page about the current Atari resources on the web.

DML has a nice page about Atari and engineering.

Peter Dassow has a nice page with a lot of links to ST software.

George Nakos used the cross-tools for his raptorBASIC+.

Jookie uses the cross-tools for developing CosmosEx software. CosmosEx is a hardware extension as small as a floppy drive which brings SD-Card, USB, Ethernet and much more to Atari computers.


Back to the software page