Difference between revisions of "Build (and use) a cross-toolchain using Dan Kegel's crosstool 0.38"

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search
(Cygwin #cygwin)
(Links: fixed link)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{Template:Articles}}
 +
''<font color=red><small>
 +
This article
 +
Based on work by moomoo, frontalot, and timtimred.
 +
Originally by frontalot.
 +
at Linkstationwiki.org
 +
</small></font>''<br>
 
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.  
 
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.  
  
Line 5: Line 12:
  
  
We will build the cross-toolchain using the GPL source code provided by Buffalo Technology, a custom kernel .config, custom build scripts, and [[http://kegel.com/crosstool/ Dan Kegel's crosstool scripts]]. You can download all of these from the [[http://www.linkstationwiki.net/downloads downloads area]].
+
We will build the cross-toolchain using the GPL source code provided by Buffalo Technology, a custom kernel .config, custom build scripts, and [[http://kegel.com/crosstool/ Dan Kegel's crosstool scripts]]. You can download all of these from the [[http://www.nas-central.org/downloads 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:
 
* 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:
Line 55: Line 62:
 
  tar -pzxvf linux-2.4.17_mvl21-sandpoint.tar.gz
 
  tar -pzxvf linux-2.4.17_mvl21-sandpoint.tar.gz
  
* Download and apply any available [[http://www.linkstationwiki.net/downloads patches]]. The 2.4.17_mvl21-sandpoint kernel needs 2 patches:
+
* Download and apply any available [[http://www.nas-central.org/downloads patches]]. The 2.4.17_mvl21-sandpoint kernel needs 2 patches:
  
 
  patch -p1 < netfilter.patch
 
  patch -p1 < netfilter.patch
Line 98: Line 105:
 
  ln -s /Volumes/MyUFSVolume/lsdev /opt
 
  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 [[http://www.linkstationwiki.net/downloads 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 - 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 [[http://www.nas-central.org/downloads 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 [[http://connect.apple.com/ | Apple Developer Connection]] and downloading the latest XCode installer.
 
* OS X 10.4 only - You will need the Apple developer tools. You can obtain them by registering at [[http://connect.apple.com/ | Apple Developer Connection]] and downloading the latest XCode installer.
Line 115: Line 122:
  
 
* Due to Windows' administrator design, Cygwin lacks a "root" user. You may encounter various file ownership issues.
 
* Due to Windows' administrator design, Cygwin lacks a "root" user. You may encounter various file ownership issues.
 +
 +
== Links ==
 +
* [http://general.nas-central.org/wiki/Setting_up_the_codesourcery_toolchain_for_X86_to_ARM9_cross_compiling Setting up the codesourcery toolchain for X86 to ARM9 cross compiling]
 +
* [[Precompiled C Cross-Toolchain]]
  
 
[[Category:General]]
 
[[Category:General]]
 +
[[Category:HG]]
 +
[[Category:LS2]]
 +
[[Category:LS1]]
 +
 +
[[Category:Development]]

Latest revision as of 14:48, 10 July 2010

This article Based on work by moomoo, frontalot, and timtimred. Originally by frontalot. at Linkstationwiki.org
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:
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:
TARBALLS_DIR=/usr/tmp/downloads
  • where it will save source tarballs
RESULT_TOP=/usr/local/linkstation
  • where it will install the toolchain
GCC_LANGUAGES="c,c++"
  • 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:
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:
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):
export PATH=$PATH:/usr/local/linkstation/gcc-3.3.5-glibc-2.3.2/powerpc-hdhlan-linux/bin
  • 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)

Notes

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:
source /etc/profile

Cygwin #cygwin

  • 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.

Links