Time to update to gcc 4.6.2

Chilly Willy

Established Member
Building a Genesis/32X toolchain

1 - Go here and download the following:

gcc-4.6.2.tar.bz2

Decompress it to wherever you keep your projects; you should end up with a folder called gcc-4.6.2.

2.1 - Go here and download mpfr-2.4.2.tar.bz2.

2.2 - Go here and download mpc-0.9.tar.gz.

2.3 - Go here and download gmp-5.0.4.tar.bz2.

Decompress them all in the same folder. You should have three folders called mpfr-2.4.2, mpc-0.9, and gmp-5.0.4. Rename them to get rid of the version numbers, leaving you with mpfr, mpc, and gmp. Copy them into the gcc-4.6.2 folder.

3 - Go here and download binutils-2.22.tar.bz2.

Decompress it in the same folder as the gcc folder so that you have two folders - gcc-4.6.2 and binutils-2.22.

4 - Go here and download newlib-1.20.0.tar.gz.

Decompress it in the same folder as gcc and binutils, leaving you with the folders - gcc-4.6.2, binutils-2.22, and newlib-1.20.0.

5 - Get this archive and decompress it to the same place as the previous directories. You should have two more directories, bin and ldscripts, in addition to the file, makefile-sega.

6 - If you wish to leave the makefile with the default path of /opt/toolchains/sega, make sure you have permission to write to /opt or the toolchain will fail to install to the path. Since there's nothing critical in /opt, it's easiest just to do "sudo chmod 777 -R /opt" which allows anyone to do anything they want in /opt.

7 - Run "make -f makefile-sega" - depending on the speed of your computer, in an hour or two you should have two toolchains in /opt/toolchains/sega: m68k-elf and sh-elf. Copy the ldscripts and bin directories to /opt/toolchains/sega.

You now have the latest gcc, binutils, and newlib for both the 68000 and the SH2. Both have compilers for C, C++, Objective-C, and Objective-C++. The bin directory has a few common tools one might use for compiling Z80 code for the MD. Copy whatever other tools you use into it, like sixpack or bin2c.

Note: The size of the built toolchain can be reduced by stripping the debug symbols from the executables in the bin directories, and by deleting the libraries meant for CPUs other than the 68000 and SH2. For example, you don't need the libraries for the 68020 or 68040 or SH3 or SH4, etc.

Here is an archive with example code - it includes Tic-Tac-Toe in both C and C++ for both the MD and the 32X. You should be able to compile them with the toolchain you just built. They should run on an emulator like Kega Fusion or Gens/GS, or on a real MD/32X with a flash cart.

Here are a few archives of things I've built for the 32X using the toolchain. They should all build and run fine using this toolchain.

32xrick-20120212.7z

Wolf32X-20120212.7z

TremorTest-20120212.7z

yeti3d-20120212.7z

Here is an archive with three libraries. You will need them for the Tremor example. Build them BEFORE trying to build the Tremor test. Be sure to run "make install" to install the libraries into the toolchain so it can find them.

Note: You don't need to set any environment variables for this toolchain as long as you use the default path for the toolchain (/opt/toolchains/sega). The examples and games come with a binary image for people who wish to try them without needing to build anything.
 
Back
Top