../../src/gcc-4.6.4/configure --target=mipsel-linux --prefix=/home/charles/code/cross-compile/embedded-toolchain/tool-chain --without-headers --enable-languages=c,c++ --disable-shared --disable-threads --disable-decimal-float --disable-libmudflap --disable-lipssp --with-float=soft
CC=mipsel-linux-gcc AR=mipsel-linux-ar RANLIB=mipsel-linux-ranlib ../../src/glibc-2.18/configure --host=mipsel-linux --prefix=/home/charles/code/cross-compile/embedded-toolchain/tool-chain/mipsel-linux --enable-add-ons --with-headers=/home/charles/code/cross-compile/embedded-toolchain/tool-chain/mipsel-linux/include --with-fp=no
../../src/gcc-4.6.4/configure --target=mipsel-linux --prefix=/home/charles/code/cross-compile/embedded-toolchain/tool-chain --disable-multilib --disable-libssp --disable-nls --disable-libstdcxx-pch --with-arch=mips32r2 --with-mips-plt --with-float=soft --with-ppl=/usr/local --disable-libgomp --enable-poison-system-directories --enable-symvers=gnu --enable-long-long --enable-threads --enable-languages=c,c++ --enable-shared --enable-lto --enable-__cxa_atexit --with-gnu-as --with-gnu-ld
然后 , 执行:
make all-gcc -j10 -i -k
make install-gcc
需要注意的问题:
1)最后一步编译 gcc 的时候,如果直接执行 make 会报错,正确的方法是 make all-gcc
2)因为 对gcc做了 配置 --with-float=soft, 在编译 glibc的时候也要做相应的配置: with-fp=no(不使用hardware float),否则生成的gcc 编译文件的时候,会报找不到文件gnu/stubs-o32_soft.h 的错误.
最后可以查看一下 生成的 gcc信息:
$ ./mipsel-linux-gcc -v Using built-in specs. COLLECT_GCC=./mipsel-linux-gcc COLLECT_LTO_WRAPPER=/home/charles/code/cross-compile/embedded-toolchain/tool-chain/libexec/gcc/mipsel-linux/4.6.4/lto-wrapper Target: mipsel-linux Configured with: ../../src/gcc-4.6.4/configure --target=mipsel-linux --prefix=/home/charles/code/cross-compile/embedded-toolchain/tool-chain --without-headers --enable-languages=c,c++ --disable-shared --disable-threads --disable-decimal-float --disable-libmudflap --disable-lipssp --with-float=soft : (reconfigured) ../../src/gcc-4.6.4/configure --target=mipsel-linux --prefix=/home/charles/code/cross-compile/embedded-toolchain/tool-chain --disable-multilib --disable-libssp --disable-nls --disable-libstdcxx-pch --with-arch=mips32r2 --with-mips-plt --with-float=soft --with-ppl=/usr/local --disable-libgomp --enable-poison-system-directories --enable-symvers=gnu --enable-long-long --enable-threads --enable-languages=c,c++ --enable-shared --enable-lto --enable-__cxa_atexit --with-gnu-as --with-gnu-ld Thread model: posix gcc version 4.6.4 (GCC)
这个比较简单,下载代码gdb-7.6.2.tar.bz2, 解压后,配置如下:
../../src/gdb-7.6.2/configure --build=i686-pc-linux-gnu --target=mipsel-linux --prefix=/home/charles/code/cross-compile/embedded-toolchain/tool-chain然后执行 make, make install 既可以了。
最后,可以用一个mips的镜像测试一下:
./mipsel-linux-gcc -g test.c -o test charles@taotao:~/code/cross-compile/embedded-toolchain/tool-chain/bin$ file test test: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), for GNU/Linux 2.6.16, with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x3040000, not stripped charles@taotao:~/code/cross-compile/embedded-toolchain/tool-chain/bin$ ./mipsel-linux-gdb GNU gdb (GDB) 7.6.2 Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=i686-pc-linux-gnu --target=mipsel-linux". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. (gdb) file test Reading symbols from /home/charles/code/cross-compile/embedded-toolchain/tool-chain/bin/test...done. (gdb) dis disable disassemble disconnect display (gdb) disassemble No frame selected. (gdb) disassemble main Dump of assembler code for function main: 0x00400700 <+0>: addiu sp,sp,-32 0x00400704 <+4>: sw ra,28(sp) 0x00400708 <+8>: sw s8,24(sp) 0x0040070c <+12>: move s8,sp 0x00400710 <+16>: lui v0,0x40 0x00400714 <+20>: addiu a0,v0,2288 0x00400718 <+24>: jal 0x400940 <puts@plt> 0x0040071c <+28>: nop 0x00400720 <+32>: move sp,s8 0x00400724 <+36>: lw ra,28(sp) 0x00400728 <+40>: lw s8,24(sp) 0x0040072c <+44>: addiu sp,sp,32 0x00400730 <+48>: jr ra 0x00400734 <+52>: nop End of assembler dump.