Differences between revisions 1 and 5 (spanning 4 versions)
Revision 1 as of 2007-10-18 17:01:31
Size: 1396
Editor: ?ArthurLoiret
Comment:
Revision 5 as of 2007-10-18 19:19:46
Size: 3236
Editor: ?ArthurLoiret
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
The goal is to setup a cross compiler to build glibc and then cross-compilong the sh4 native toolchain. The goal is to setup a cross compiler to build glibc and then cross-compiling the sh4 native toolchain.
Line 5: Line 5:
First, you must understant what does host, build and target correspond to: First, you must understand what does host, build and target correspond to:
Line 10: Line 10:
Now let's build that. == Current cross-toolchain repository ==
Line 12: Line 12:
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 =
Line 29: Line 36:
== gcc == == cross-gcc ==
Line 35: Line 42:
Get libc6-dev-sh4-cross and all its deps on http://people.dunnewind.net/arthur/sh4/cross/ ./ Get libc6-dev-sh4-cross and all its deps on http://people.dunnewind.net/arthur/sh4/cross/
Line 47: Line 54:

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:

 $ apt-get source glibc
 $ fakeroot debian/rules unpack

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

Build the glibc:

 $ fakeroot debian/rules binary

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

 $ for i in *_sh4.deb; do dpkg-cross -A -a sh4 -b $i; done

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


= gcc =

Go back to your gcc sources dir

 $ fakeroot debian/rules clean

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

 $ fakeroot debian/rules binary

That's all!


= binutils (again) =

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

 $ fakeroot debian/rules clean

Check dpkg-architecture -ash4 -s ...

 $ fakeroot debian/rules binary


You now have a full sh4 toolchain. :-)

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:

  • host = The host arch where the code is supposed to _run_
  • build = The arch from where you _build_ the code
  • target = The arch that the code is supposed to _generate_ code for

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:

  • $ apt-get source binutils

Go to the source dir:

  • $ binutils-2.18/

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

  • $ TARGET=sh4-linux-gnu fakeroot debian/rules binary-cross

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:

  • $ apt-get source gcc-4.2 $ cd gcc-4.2-4.2.2/ $ GCC_TARGET=sh4 fakeroot debian/rules binary

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:

  • $ apt-get source glibc $ fakeroot debian/rules unpack

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

Build the glibc:

  • $ fakeroot debian/rules binary

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

  • $ for i in *_sh4.deb; do dpkg-cross -A -a sh4 -b $i; done

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

gcc

Go back to your gcc sources dir

  • $ fakeroot debian/rules clean

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

  • $ fakeroot debian/rules binary

That's all!

binutils (again)

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

  • $ fakeroot debian/rules clean

Check dpkg-architecture -ash4 -s ...

  • $ fakeroot debian/rules binary

You now have a full sh4 toolchain. :-)