构造arm-linux交叉编译工具链(Tool Chain)

 Linux kernel package used: (ftp://ftp.kernel.org/pub/linux/kernel/v2.6/)
linux-2.6.17.tar.gz

GNU compiler sources: (ftp://ftp.gnu.org/gnu/)
binutils-2.17.tar.gz
gcc-3.4.6.tar.gz
glibc-2.3.6.tar.gz
glibc-linuxthreads-2.3.6.tar.gz

Patches used: (http://sources.gentoo.org/viewcvs.py/gentoo/src/patchsets/)
33_all_pr15068-fix.patch
5090_all_divdi3-asm-fix.patch
6200_all_arm-glibc-2.3.6-ioperm.patch
6230_all_arm-glibc-2.3.6-socket-no-weak-lias.patch
gcc_eh.patch.cross

1. Preparation
Create project directory like this:
/root/scholar
     |
     |--toolchain
     |  |--binutils-2.17.tar.gz
     |  |--gcc-3.4.6.tar.gz
     |  |--glibc-2.3.6.tar.gz
     |  |--glibc-linuxthreads-2.3.6.tar.gz
     |
     |--patches
     |  |--33_all_pr15068-fix.patch
     |  |--5090_all_divdi3-asm-fix.patch
     |  |--6200_all_arm-glibc-2.3.6-ioperm.patch
     |  |--6230_all_arm-glibc-2.3.6-socket-no-weak-lias.patch
     |  |--gcc_eh.patch.cross
     |
     |--kernel
        |--linux-2.6.17.tar.gz

export PREFIX=/usr/local/arm/scholar

2. Building binutils-2.17
tar -zxvf binutils-2.17.tar.gz
cd binutils-2.17
mkdir arm-linux
cd arm-linux
../configure --target=arm-linux --prefix=$PREFIX --program-prefix=arm-linux-
make
make install

3. Bootstrap GCC (First time compiling GCC without glibc, only pure-C is supported)
tar -zxvf gcc-3.4.6.tar.gz
patch -p1 -d gcc-3.4.6 < patches/33_all_pr15068-fix.patch
cd gcc-3.4.6
vi gcc/config/arm/t-linux (TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC -Dinhibit_libc -D__gthr_posix_h)
mkdir arm-linux
cd arm-linux
../configure --target=arm-linux --prefix=$PREFIX --program-prefix=arm-linux- --disable-threads --disable-shared --enable-languages=c
make
make install

4. Linux kernel header files (This step creates the arm-specified header files for glibc)
tar -zxvf linux-2.6.17.tar.gz
cd linux-2.6.17
make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig
make include/linux/version.h
cp -dR include/linux $PREFIX/arm-linux/include/
cp -dR include/asm-generic $PREFIX/arm-linux/include/
cp -dR include/asm-arm $PREFIX/arm-linux/include/
mv $PREFIX/arm-linux/include/asm-arm $PREFIX/arm-linux/include/asm

5. glibc-2.3.6
tar -zxvf glibc-2.3.6.tar.gz
tar -zxvf glibc-linuxthreads-2.3.6.tar.gz --directory ./glibc-2.3.6
patch -p1 -d glibc-2.3.6 < patches/5090_all_divdi3-asm-fix.patch
patch -p1 -d glibc-2.3.6 < patches/6200_all_arm-glibc-2.3.6-ioperm.patch
patch -p1 -d glibc-2.3.6 < patches/6230_all_arm-glibc-2.3.6-socket-no-weak-lias.patch
patch -p1 -d glibc-2.3.6 < patches/gcc_eh.patch.cross
mkdir arm-linux
cd arm-linux
CC=arm-linux-gcc AR=arm-linux-ar RANLIB=arm-linux-ranlib LD=arm-linux-ld ../configure --target=arm-linux --prefix=$PREFIX/arm-linux --host=arm-linux --enable-add-ons=linuxthreads --enable-shared --with-headers=$PREFIX/arm-linux/include
make
make install

6. gcc-3.4.6 full version (with glibc, support C/C++)
cd gcc-3.4.6
Change ./gcc/config/arm/t-linux back to original
cd arm-linux
../configure --target=arm-linux --prefix=$PREFIX --program-prefix=arm-linux- --enable-multilib --with-headers=$PREFIX/arm-linux/include --enable-languages=c,c++
make
make install

自此,整个arm-linux的工具链也就生成了.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值