About
Scratchbox toolchains have always been under a lot of changes. This wiki page is for keeping the newest toolchain documentation. These pages mainly concern about building toolchains. Using prebuilt ForeignToolchains is the recommended way as of Scratchbox Apophis and newer.
1. Compiling toolchains
You need to have Scratchbox 1.0.x installed.
Your normal user account must have write access to the /scratchbox/compilers directory and all directories under /scratchbox/device_tools.
Log into Scratchbox and use sb-menu to change the HOST target (using Setup):
select the "debian" devkit (if you have several debian devkits, use "debian-etch")
install "Devkit" and "/etc" files
re-select the HOST target
Extract the sb-toolchains build tree under your Scratchbox home directory and go to that directory (~/sb-toolchains):
-
> darcs get http://scratchbox.org/repos/1.0/sb-toolchainsIf you have already used sb-toolchain with this session, just run make clean CONFIG=meta/alien-tc/your_previous_toolchain.conf
-
Choose one of the meta/toolchain/*.conf configurations or write your own (based on one of the existing ones).
Build the toolchain including all optional tools:
-
> make CONFIG=meta/toolchain/my.conf
-
The toolchain is now ready to use (use sb-menu to create a new Scratchbox target).
You can create tarball and Debian packages inside Scratchbox:
-
> make CONFIG=meta/toolchain/my.conf tarball deb
-
You can create RPM packages outside Scratchbox if you have rpmbuild:
-
> make CONFIG=meta/toolchain/my.conf rpm
-
If you think you don't need to work on this toolchain any more, clean sb-toolchain-extras to avoid issues wen you will try to compile another toolchain
-
> make CONFIG=meta/toolchain/my.conf clean
-
1.1 Testing the compiled toolchain
At the moment the reg_test.sh script runs the gcc, g++ and libstdc++ tests. In the future also the binutils tests should be included.
In the Scratchbox's HOST target build the dejagnu
-
> make -C test_tools/dejagnu install
-
Set up a Scratchbox target that uses the new toolchain. Select a CPU-transparency method and install the C-library files.
Go to the sb-toolchains/test_tools/test_scripts directory and run the initial tests:
-
> ./init_tests.sh FILE_TYPE
-
If they went all ok then run the dejagnu tests:
-
> ./reg_tests.sh COMPILER_DIR
-
2. The toolchain build environment
2.1 Build directories
The toolchain build tree has separate directories for building each of the toolchain components.
The main directory layout is the following:
meta - meta Makefiles and toolchain configuration files
libc - glibc and uClibc C-libraries
cc - the GCC compiler
binutils - binutils
toolchain - kernel headers and post install scripts (bad name?)
2.2 Build configuration files
The toolchain configuration files defines mainly:
toolchain CPU type
use of soft-float or hard-float
toolchain build directories
build sources and patches
Common build variables are defined in the sb-toolchain/<component>/category.mk files. These files are repeated for all components so this might change in the future.
uClibc uses a kernel like configuration so we use separate uClibc configuration files for different architectures. These files are found under the sb-toolchain/uclibc/files and sb-toolchain/uclibc-headers/files directories.
3. Architecture support
3.1 New architectures
Scratchbox uses Binfmt_misc for redirecting target binaries. Binfmt_misc needs to now the architecture specific magic numbers of the binary files. Scratchbox uses the /scratchbox/sbin/register_misc_runner script for registering the binary formats. At the moment new architectures can be added by manually editing the register_misc_runner file. A list of magic numbers can be found in the /usr/include/elf.h file.
Here is an example of adding cris support
+++ /scratchbox/sbin/register_misc_runner 2005-08-15 14:14:20.000000000 +0300 @@ -32,2 +32,3 @@ deregister i386 +deregister cris deregister mips @@ -82,2 +83,3 @@ register i386 little '\x03' +register cris little '\x4c' register mips big '\x08'
3.2 Special issues
The toolchain build system has been tested with several different architectures. Some of them have special issues.
3.3 Crocodile
The toolchains need to have some aditional features set for Crocodile. For examples see the arm-gcc3.4.cs-glibc.conf and cris-gcc3.4-uclibc.conf files. The toolchain needs to have proper debian packages for libc, libstd++, gcc, kernel headers and fakeroot. The config file needs the following additional variables defined:
CC_DEBIAN_DIR
LIBC_DEBIAN_DIR
CC_FULLVER
uClibc Crocodile needs some more stuff to be done. The config file needs also the following
GETTEXT_VER
GETTEXT_SRC
Before building an uClibc toolchain you need to add uclibc target support for Debian. Edir the /scratchbox/devkits/debian/bin/dpkg-architecture file and add a line to the archtable e.g.:
%archtable=('i386', 'i386-linux',
+ 'arm', 'arm-linux-uclibc',
'sparc', 'sparc-linux',
uClibc toolchains need yet more. After the toolchain is built and a new Scratchbox target is created then the gcc prefix list variable should be updated. The <TARGET>.config file should have a line like SBOX_CROSS_GCC_PREFIX_LIST=arm-linux-uclibc-:arm-linux-
4. Related pages