Difference between revisions of "Build (and use) a cross-toolchain using Dan Kegel's crosstool 0.38"
|Line 126:||Line 126:|
Revision as of 07:33, 17 July 2006
Based on work by moomoo, frontalot, and timtimred.
Originally by frontalot.
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.
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:
mv powerpc-hdhlan.config /usr/tmp/crosstool-0.38 mv powerpc-hdhlan.dat /usr/tmp/crosstool-0.38 mv powerpc-hdhlan.sh /usr/tmp/crosstool-0.38 mv gcc-3.3.5-glibc-2.3.2.dat /usr/tmp/crosstool-0.38
- Open powerpc-hdhlan.sh in a text editor and adjust the configuration variables if needed. For our example:
- where it will save source tarballs
- where it will install the toolchain
- which languages it will make compilers for
- Uncomment the toolchain you want to build. To build a gcc-3.3.5-glibc-2.3.2 toolchain:
eval `cat powerpc-hdhlan.dat gcc-3.3.5-glibc-2.3.2.dat` sh all.sh --notest
- 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:
- which version of binutils to build
- which version of gcc to build
- which version of glibc to build
- which version of glibc-linuxthreads to build (same as glibc version)
- 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:
rm linux-2.4.17_mvl21-sandpoint.tar.gz tar -pczvf linux-2.4.17_mvl21-sandpoint.tar.gz linux-2.4.17_mvl21-sandpoint@@
- See the following notes for OSX and 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 ./powerpc-hdhlan.sh
- The build process may take several hours. You also may see some warnings during the build process - do not worry, this is fairly typical.
Using a Cross-Toolchain
- Add the cross-toolchain to your $PATH (you can do this in .bashrc):
- Then declare the host and/or target type when running a program's ./configure script (this varies from program to program):
./configure --host=powerpc-hdhlan-linux --target=powerpc-hdhlan-linux
- Or specify the cross-toolchain's development programs when using make:
make AR=powerpc-hdhlan-linux-ar CC=powerpc-hdhlan-linux-gcc LD=powerpc-hdhlan-linux-ld NM=powerpc-hdhlan-linux-nm OBJDUMP=powerpc-hdhlan-linux-objdump
- (all one line)
Mac OS X #osx
- 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.