Sunday, January 09, 2005

uclibc cross compiler

First I cheated. I used the gcc cross compiler that came from the uclibc
libc project. Why? It seems to be very stable, I seemed to work on mandrake 9.2
and 10.x and gentoo, and probably debian woody. I started out using ptxdist 0.4.0 to build a small system but ptxdist 0.4.0 didnt work on mandrake 9.2. (Mandrake 9.2 runs the wireless card i have as well as vmware).

The uclibc compiler uses a Canadian Cross [1] and this is abbreviated set of steps are:

1. Setup the Kernel headers and locate in the correct dir.
2. Build Binutils.
3. Build Bootstrap GCC with no headers and c only.
4. Build GLibc/uClibc
5. Build GCC with full support for c,c++ and headers and uClibc.

the files used in the build system are:
binutils-uclibc.mk
elf2flt.mk
kernel-headers.mk
sed.mk
ccache.mk
gcc-uclibc-3.3.mk
libfloat.mk
uclibc.mk

These all came from the uclibc project's gcc.3.3.x tarball
but have been modified to be used inside a modified ptxdist project.

The original uclibc toolchain project [5] contained a toplevel Makefile, this was moved into the file Virtual.make.

The trick that gets Virtual.make to work is to include all the .mk files
and define a backbone of target dependencies. This is done with the statment:
TARGETS+=host-sed kernel-headers uclibc-configured binutils gcc3_3 ccache
Later the statement

.PHONY: world $(TARGETS)
says please build all these targets which are defined in the included makefiles.


1. The file binutils-uclibc.mk will build the the binary utilies (strip ar) these are necessary to build the compiler.

2. The file kernel-headers.mk while build the kernle headers. The kernel header describe the type of system you have: i386 versus ARM verus MIPS and sizes of basic types.

3. The file gcc-uclibc-3.3.mk Is used to build the bootstrap compiler and later the full compiler. A bootstrap compiler is a static compiler with only c languague support. The bootstrap compiler also depends on the uclibc.mk make file or rather the ublic system to be unpacked and configured. The second pass compiler depends on static build compiler and the build uclibc.
see the line:
gcc3_3_target: uclibc_target binutils_target $(TARGET_DIR)/usr/bin/gcc

4. file elf2flt.mk is only compile for mmuless systems with is not i386 system and doesnt apply to us.

5. File sed.mk is used to make sed for target systems.

http://kegel.com/crosstool/crosstool-0.28-rc37/doc/crosstool-howto.html
[2] http://efault.net/npat/docs_and_postings/cross-toolchain-build/cross-toolchain-build.txt
[3] http://sources.redhat.com/autobook/autobook/autobook_17.html
[4] http://www.airs.com/ian/configure/
[5] http://www.uclibc.org/cgi-bin/cvsweb/toolchain/gcc-3.3.x

No comments: