Foreign Toolchains
This page describes how to use foreign toolchains, ie toolchains compiled outside scratchbox, such like
CodeSourcery,
BuildRoot or
crosstool.
Finding a suitable toolchain for scratchbox
Not all prebuilt toolchains are going to work with sb. For arm, the toolchain should have C library and binutils, support for dynamic libraries, no TLS support (or relatively new qemu and/or 2.6 target kernel).
Installation
Unpacking
Extract the prebuilt toolchain to your COMPILER_DIR: eg. /scratchbox/compilers/arm-linux-withmyhacks .
The COMPILER_DIR should probably now have subdirectories like bin,your-arch-name and lib.
For the alien wrapper to work, you must have Scratchbox version 1.0.3 or newer (Apophis branch) and the compiler must work when invoked directly, eg.
/scratchbox/compilers/arm-linux-withmyhacks/bin/your-arch-name-gcc --version
Configuring
To actually use the foreign toolchain in the scratchbox compilation environment, some configuration must be done. To be more precise, we need some tools for the target (eg. sbrsh, strace, fakeroot, gdb), some toolchain specific tools to the scratcbox (eg. libtool), a script to setup the target for this toolchain, and some meta-information about the architecture of the target so that scratchbox can provide sane build environment.
Fortunately, there are some more tools to aid through the configuration process.
Setup the system as in building native Toolchains (Compiling toolchains, steps 1-3), with exception that you must have perl and doctools devkits selected as well
Unpack the toolchain you intend to use to /scratchbox/compilers/your-cool-compiler
Fetch sb-toolchain-extras repository.
darcs get --set-scripts-executable http://scratchbox.org/repos/1.0/sb-toolchain-extras
Create the configuration file.
This can be either done manually, or by using a helper.
Configuring using the create_toolchain_conf -helper
Go to /scratchbox/compilers/your-cool-compiler directory.
Run the helper-script
~/sb-toolchain-extras/confhelper/create_toolchain_conf.py
If the output looks sensible, you should store it inside sbtc-extras tree
~/sb-toolchain-extras/confhelper/create_toolchain_conf.py > ~/sb-toolchain-extras/meta/alien-tc/arm-mycoolhacks.conf
Even if there is something wrong with the config, you can probably use that as a starting point in making the final configuration.
Configuring manually
Create your own configuration file into meta/alien-tc directory.
You can use some of the provided ones as a template.
Building auxiliary tools
Auxillary tools are toolchain-specific tools such as sbrshd, fakeroot, gdb and strace. these typically come with the toolchain package.
Change to ~/sb-toolchain-extras directory
If you are building the toolchain for the first time (eg. you have created a new config), you have to build the checksums too.
make CONFIG=meta/alien-tc/yourconfig.conf -C meta/alien-tc all-sums
Build toolchain extras:
make CONFIG=meta/alien-tc/yourconfig.conf -C meta/alien-tc
Create new target
Now you can use sb-menu to setup the target as usual. For quick testing, you can use tests/env/run.sh from http://scratchbox.org/repos/1.0/scratchbox.
Building packages
For redistribution, you probably want to build packages when you have working toolchains. Remember to redistribute the sources as well.
make tarball deb CONFIG=meta/alien-tc/yourconfig.conf
Former Issues
Target C library is not found at runtime
/lib/libc.so and/or /usr/lib/libc.so might contain absolute(and incorrect) pathnames; they should be removed.
The shadow package fails
You might get something like
aclocal: configure.in: 12: macro `AM_DISABLE_SHARED' not found in library aclocal: configure.in: 13: macro `AM_ENABLE_STATIC' not found in library aclocal: configure.in: 21: macro `AM_PROG_LIBTOOL' not found in library
if the libtool exists, but is misconfigured. Some versions don't install the m4 files to ./share/aclocal.
Perl
Perl might not compile, especially when using sbrsh. Most of the issues can be circumvented by compiling miniperl using host-gcc instead of target-gcc. Patch taken and modified from MIPS Crocodile.
Other issues
Depending on your toolchain, you might need some additional compiler-prefixes into your scratchbox.config for some build-systems. Just add those to /targets/links/scratchbox.config, line SBOX_CROSS_GCC_PREFIX_LIST
e.g. If you get error like this:
make[1]: Entering directory `/home/jussi/crocodile/work/build/zlib-1.2.2/build-tree/zlib-1.2.2' arm-linux-gcc -O3 -g -D_REENTRANT -fPIC -DNO_snprintf -DHAS_sprintf_void -DNO_ERRNO_H -c -o example.o example.c sb_gcc_wrapper (arm-linux-gcc): arm-linux-gcc cannot be recognized Maybe you are trying to run a compiler of a wrong architecture? make[1]: *** [example.o] Error 1
then just add arm-linux- to SBOX_CROSS_GCC_PREFIX_LIST in /targets/links/scratchbox.config.
Toolchains