最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

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

工作和技术 crifan 2125浏览 0评论

【转】构造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的工具链也就生成了.

转载请注明:在路上 » 【转】构造arm-linux交叉编译工具链(Tool Chain)

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (3)

  1. gcc_eh.patch.cross这个补丁包找不到呀,为什么?
    qiuzhi17年前 (2008-03-16)回复
  2. gcc_eh.patch.cross这个补丁包找不到呀,为什么?
    qiuzhi17年前 (2008-03-16)回复
  3. gcc_eh.patch.cross这个补丁包找不到呀,为什么?
    qiuzhi17年前 (2008-03-16)回复
82 queries in 0.198 seconds, using 22.12MB memory