Development tools

Porting gcc 3.3.6 to MiNT, C language support, v 0.3

This text tries to explain the steps to port gcc 3.3.6 from original sources to a working MiNT port. Current gcc version for MiNT is 2.95.3, albeit working, a more recent version can be needed to compile recent software.

Step 1: Get the necessary archives

You need original gcc 3.3.6 archive. The archive decompress to a 185 MB of source directory. You will also need autoconf and automake to rebuild needed and configure scripts.

$ tar xvjf gcc-3.3.6.tar.bz2
$ mkdir gcc-3.3.6-mint

You also need a standard C library for the target, like mintlib for example (both standard and debugging versions), because gcc will need to build some stuff for the target (like libiberty and libgcc libraries). You can retrieve current mintlib development files from Sparemint website. They are in RPM format but you can convert them to tar.gz by using alien program. You need to unpack mintlib at the final place ($TARGETPATH/m68k-atari-mint). You should have headers in include subdir, and lib in another subdir.

You also need binutils to create MiNT binaries/libraries.

Step 2: First try

Note: TARGETPATH is a directory where gcc-mint will be installed. We modify the PATH variable so the build process will find the binutils needed to build MiNT binaries. We will configure gcc with C language support atm. Change the '/path/to/mintlib' to the absolute path to where you unpacked mintlib development files.

$ mkdir gcc-3.3.6-mint
$ cd gcc-3.3.6-mint
$ export PATH=${TARGETPATH}/bin:PATH
$ ../gcc-3.3.6/configure --prefix=${TARGETPATH} --target=m68k-atari-mint

First error:

*** Configuration m68k-atari-mint not supported
Configure in /home/patrice/src/utils/gcc-3.3.6-mint/gcc failed, exiting.

Step 3: Patch gcc to accept m68k-atari-mint target

This is done in three files.

Step 3.1: gcc/config.gcc

Well, we just need to add our target:


Oh, yes we need those two files.

Step 3.2: gcc/config/m68k/mint.h

This file is very tricky, because it controls what gcc can do about code generation and optimizations. An error there may cause gcc not ouputting working code for our target. You should note in this subdir the file atari.h to support Atari SVR4. This is also in this file where command line flags for the target are defined, and which are the default defines, all of which will end in the spec file.

mint.h (gcc 2.95.3 version).

This file has not changed much for gcc 3.3. Some stuff has been removed.

Step 3.3: gcc/config/m68k/t-mint

This is roughly the same as t-m68kbare. We just change the multilib stuff that will be build, i.e. only 68000 (no fpu), 68020 (no fpu) and 68020-60 (fpu). And each of these will be build with or without -mshort flag for people wanting to link gcc object files against Pure C (A 16 bits compiler for a 32 bits m68k cpu? too much ported from turbo C/dos). I think we should drop this flag.

Step 3.4: Rerun configure

OK, gcc is configured to build a cross-compiler for m68k-atari-mint target.

Step 4: Make

Note: you can build the 'bootstrap' target (if you are not cross-compiling), which is a 3 pass compilation: (1)build gcc with current compiler (2) build gcc with gcc compiled at stage 1 (3) build gcc with gcc compiled at stage 2, and compare the two binaries. If they are not the same, gcc produced an incorrect program.

But as we are building a cross-compiler, we can't do that, so we just run make.

$ make

You will notice many warning messages, specially when building the floating point stuff.

Step 5: Install

$ make install

Step 6: Time to test and debug!

Apparently the build is ok, but we must be sure the code generated/linked by all these tools is right. That's the hard part. Most of these tools have testsuite, but maybe it requires writing MiNT tests as well.

Here is the final patch:

Personnal productions
Development tools
Create a patch for binutils (binutils 2.16.1)
Create a patch for gcc (gcc 3.3.6, C language only)
Create a patch for gcc (gcc 3.3.6, C++ language)
Misc stuff

HTML 4.0 valide ! La montée de Pikes Peak Non aux brevets logiciels Nectarine demoscene radio
Write me to pmandin(at)caramail(point)com
(Address modified for spam protection)