SH4 Cross Toolchain howto

The goal is to setup a cross compiler to build glibc and then cross-compiling the sh4 native toolchain.

First, you must understand what does host, build and target correspond to:

Current cross-toolchain repository

Add "deb http://people.dunnewind.net/arthur/sh4/cross/ ./" to your sources.list

Install gcc-4.1-sh4-linux-gnu libc6-dev-sh4-cross or whatever you want.

Build our own toolchain

binutils

Get the binutils sources:

Go to the source dir:

Binutils packaging system already have all the targets you'll need to build an _i386_ binutils for _sh4_ targets, just run:

You'll get a wonderful "binutils-sh4-linux-gnu_2.18-1_i386.deb", install it.

cross-gcc

Since there already are some built glibc for sh4, we are going to install them instead of bootstrapping a minimal cross-compiler just to build the glibc and rebuild a full cross-compiler then...

glibc

Get libc6-dev-sh4-cross and all its deps on http://people.dunnewind.net/arthur/sh4/cross/

The package is already dpkg-cross'ed, just install it.

gcc

As for binutils, there already are cross targets in the packaging, run:

Install the generated packages, it's time to buid glibc now

glibc

This time we'll cross-compile our first package, update dpkg-architecture first, run:

DEB_BUILD_ARCH=i386; DEB_BUILD_ARCH_OS=linux; DEB_BUILD_ARCH_CPU=i386; DEB_BUILD_GNU_CPU=i486; DEB_BUILD_GNU_SYSTEM=linux-gnu; DEB_BUILD_GNU_TYPE=i486-linux-gnu; DEB_HOST_ARCH=sh4; DEB_HOST_ARCH_OS=linux; DEB_HOST_ARCH_CPU=sh4; DEB_HOST_GNU_CPU=sh4; DEB_HOST_GNU_SYSTEM=linux-gnu; DEB_HOST_GNU_TYPE=sh4-linux-gnu; export DEB_BUILD_ARCH DEB_BUILD_ARCH_OS DEB_BUILD_ARCH_CPU DEB_BUILD_GNU_CPU DEB_BUILD_GNU_SYSTEM DEB_BUILD_GNU_TYPE DEB_HOST_ARCH DEB_HOST_ARCH_OS DEB_HOST_ARCH_CPU DEB_HOST_GNU_CPU DEB_HOST_GNU_SYSTEM DEB_HOST_GNU_TYPE

(result of dpkg-architecure -ash4 -s)

Get the sources:

Apply the following patches: http://people.dunnewind.net/arthur/sh4/patches/glibc/

Build the glibc:

You'll get sh4 binary packages, we'll need them to cross-compile gcc, run for example:

install the *-sh4-cross_*_all.deb packages

gcc

Go back to your gcc sources dir

If necessary, run the result of dpkg-architecure -ash4 -s again.

That's all!

binutils (again)

The main goal is to have a sh4 toolchain, so we have to build binutils again:

Check dpkg-architecture -ash4 -s ...

You now have a full sh4 toolchain. :-)


CategoryPorts