交叉编译器的研究

今天去食堂吃饭的时候,想到自己编译的那个交叉编译器编译内核能够运行。但是,是应用程序运行时报非法指令。想想,会不会是编译glibc的时候出了问题。看来应该是的,编译引导编译器时,没有加指定cpu的东东。

 

下面是原来编译交叉编译器的东东。有点乱

 

 

1.binutils

 

../binutils-2.20.1/configure --target=$TARGET --prefix=$PREFIX --disable-nls --disable-werror --disable-multilib --enable-shared

2.gcc pass1

../gcc-4.4.5/configure --target=$TARGET --prefix=$PREFIX --without-headers --with-newlib --with-gnu-as --with-gnu-ld --disable-nls --disable-decimal-float --disable-libgomp --disable-multilib --disable-libmudflap --disable-libssp --disable-shared --disable-threads --disable-libstdcxx-pch --disable-libffi --enable-languages=c --with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs --without-ppl -without-cloog --with-float=soft --with-arch=armv4t --with-cpu=arm920t --with-tune=arm920t

2.5

ln -vs libgcc.a `$TARGET-gcc -print-libgcc-file-name | /

sed 's/libgcc/&_eh/'`

 

3.header files

make ARCH=arm CROSS_COMPILE=${TARGET}- INSTALL_HDR_PATH=$PREFIX/$TARGET/ headers_install

 

4.glibc

BUILD_CC=gcc CC=${TARGET}-gcc AR=${TARGET}-ar RANLIB=${TARGET}-ranlib ../glibc-2.9/configure --prefix=/usr --host=$TARGET --build=$(../glibc-2.9/scripts/config.guess) -with-binutils=$PREFIX/bin -with-headers=$PREFIX/$TARGET/include --with-tls --with-__thread --enable-sim --enable-ntpl --enable-add-on --enable-kernel=2.6.37 --disable-profile --without-gd --without-cvs libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes libc_cv_arm_tls=yes libc_cv_gnu99_inline=yes --with-sysroot=$SYSROOT

 

make install_root=$PREFIX/$TARGET prefix="" install

 

BUILD_CC="gcc"

Glibc 在编译过程中需要先创建一些工具,这些工具需要用主机上的 GCC 来 编译。

CC=${TARGET}-gcc

告诉 Glibc 使用我们在上一步为 ARM 目标平台创建的交叉编译 器 GCC 来编译 C 库。

AR=${TARGET}-ar /

告诉 Glibc 使用我们在上一步为 ARM 目标平台创建的 ar 来 汇编 C 库。

RANLIB=${TARGET}-ranlib

告诉 Glibc 使用我们在上一步为 ARM 目 标平台创建的 ranlib

5.gcc pass2

../gcc-4.4.5/configure --target=$TARGET -prefix=$PREFIX --with-float=soft --enable-languages=c,c++ --enable-threads=posix --enable-c99 --enable-long-long --enable-shared --enable-__cxa_atexit --enable-nls --disable-libgomp --with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs  --with-arch=armv4t --with-cpu=arm920t --with-tune=arm920t

 

 

有的东东的问题

Under normal circumstances the GCC fixincludes script is run in order to fix potentially broken header files. As GCC-4.5.1 and Glibc-2.12.1 have already been installed at this point, and their respective header files are known to not require fixing, the fixincludes script is not required. In fact, running this script may actually pollute the build environment by installing fixed headers from the host system into GCC's private include directory. The running of the fixincludes script can be suppressed by issuing the following commands:

cp -v gcc/Makefile.in{,.orig}

sed 's@/./fixinc/.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值