* See the following notes for [[Articles/GeneralCrossToolchain#Mac_OS_X_.23osx Mac OS X]] and [[Articles/GeneralCrossToolchain#cygwin | Cygwin]] before proceeding. To build the toolchain, all you must do is run the build script; crosstool will automate the entire process!

+

* See the following notes for [[Articles/GeneralCrossToolchain#Mac_OS_X_.23osx]] and [[Articles/GeneralCrossToolchain#cygwin | Cygwin]] before proceeding. To build the toolchain, all you must do is run the build script; crosstool will automate the entire process!

cd /usr/tmp/crosstool-0.38

cd /usr/tmp/crosstool-0.38

Revision as of 12:02, 15 June 2006

Compiling programs on the LinkStation (native compiling) can take a very, very long time. A much faster method is to cross-compile programs using a cross-toolchain. A cross-toolchain allows you to compile code for the LinkStation on a faster computer with a different architecture, usually an i386/i686 desktop.

Contents

Building a Cross-Toolchain

We will build the cross-toolchain using the GPL source code provided by Buffalo Technology, a custom kernel .config, custom build scripts, and [| Dan Kegel's crosstool scripts]. You can download all of these from the [downloads area].

You will need several gigabytes of free hard drive space to build the cross-toolchain. Also, you must be logged in as a user other than root. Start by unpacking the crosstool archive:

tar -pzxvf crosstool-0.38.tar.gz

Place the appropriate custom kernel .config and custom build scripts in the crosstool directory. In this example, we will be building a gcc-3.3.5-glibc-2.3.2 toolchain for the powerpc-hdhlan LinkStation:

Make sure you have the necessary permissions and ownership for the download and installation directories. Open gcc-3.3.5-glibc-2.3.2.dat in a text editor and adjust the configuration variables. For our example:

BINUTILS_DIR=binutils-2.15

which version of binutils to build

GCC_DIR=gcc-3.3.5

which version of gcc to build

GLIBC_DIR=glibc-2.3.2

which version of glibc to build

GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.2

which version of glibc-linuxthreads to build (same as glibc version)

LINUX_DIR=linux-2.4.17_mvl21-sandpoint

which kernel source to use

Extract the kernel source code from the GPL source code archive and place it in the downloads directory previously defined. Our example calls for linux-2.4.17_mvl21-sandpoint.tar.gz. Then unpack the kernel source:

cd /usr/tmp/downloads
tar -pzxvf linux-2.4.17_mvl21-sandpoint.tar.gz

Download and apply any available [patches]. The 2.4.17_mvl21-sandpoint kernel needs 2 patches:

patch -p1 < netfilter.patch
patch -p1 < usbvideo.patch

Remove the old kernel source archive and package the patched kernel source:

Notes

Use a UFS volume on OS X. Do not use an HFS volume as there will be confusion and overwriting of files due to case insensitivity. Create an alias to your mounted UFS partition, remembering not to use spaces in the path:

ln -s /Volumes/MyUFSVolume/lsdev /opt

OS X 10.4 only - Despite there being a patch for build issues of glibc on OS X, there are still issues with version checking on things like ld and as which will break the install. Download the glibc configure file patch from the [downloads area] and put it in crosstool-0.38/patches/glibc-2.3.5/. If you are a Linux user and thinking about doing this, please don't, the version checks are there for a reason!

OS X 10.4 only - You will need the Apple developer tools. You can obtain them by registering at [| Apple Developer Connection] and downloading the latest XCode installer.

OS X 10.4 only - If you are compiling a toolchain using glibc 2.3.2, select gcc 3.3 or it will fail the version check during configure. Use gcc 4.0 for newer compilers and glibc versions or else they might break. I had to compile a gcc-3.4.4-glibc 2.3.5 toolchain with gcc 4.0 (your experience may vary). To select the gcc version you wish to use:

sudo gcc_select 4.0

OS X 10.4 only - Install wget, GNU sed and gawk. Make sure you install them in /usr/local and ensure that /usr/local/bin appears at the beginning of your PATH in /etc/profile. Then run:

Due to Windows' file case insensitivity, toolchains built under Cygwin will encounter issues with certain files, e.g., ipt_tos.h and ipt_TOS.h. This will prevent Cygwin users from building the ip_tables kernel modules.

Due to Windows' administrator design, Cygwin lacks a "root" user. You may encounter various file ownership issues.