Ubuntu下使用Crosstool制作交叉编译工具遇到的麻烦


在Ubuntu下使用crosstool制作交叉编译工具
(arm-softfloat-linux-gnu-)
为了解决softfloat问题

使用arm-linux-gcc-3.4.1和arm-linux-2.95.3交叉编译工具编译U-BOOT-1.1.6时,总是提示如下类似错误信息。
/lib_arm/_udivsi3.S:67: relocation truncated to fit: R_ARM_PLT32 __div0
lib_arm/_umodsi3.S:79: relocation truncated to fit: R_ARM_PLT32 __div0
上网搜索了一下,发现出现这个问题的还不少。网友给出的解决方法是:
1)去除编译选项soft-float
2) 重新制作交叉编译工具
试了一下,发现去除soft-float后,还是不能解决这个问题。按照网友vxworks、尔雅的方法,重新制作了cross tools,步骤如下:
1)以root登陆
2)创建目录/opt/crosstool/并修改并修改其owner。是因为此crosstool不能以root安装,而须以username安装,安装过程会读写此目录,故需要修改属主。
3)以用户username登陆
4) 创建目录/home/username/downloads这个目录将来用于自动从网上下载gcc, binutilty,glibc等。如果自己已经下载了这些软件包,也放在这个目录下,这样就不用程序自动从网上下载了。
5) 从http://kegel.com/crosstool/下载crosstool-0.43.tar.gz到目录/opt/crosstool
6) cd /opt/crosstool tar xzvf crosstool-0.43.tar.gz
7) 进入crosstool-0.43目录,执行sh demo-arm-softfloat.sh

原文作者说这样就可以成功了,但是使用Ubuntu的同学会很郁闷的发现,在该程序下载了几个小时,编了十几分钟以后,突然出现如下错误:
In file included from version.c:33:
/home/skorpio/crosstool-0.43/build/powerpc-405-linux-gnu/gcc-4.1.0-glibc-2.3.6/build-glibc/csu/version-info.h:2:1: missing terminating " character
/home/skorpio/crosstool-0.43/build/powerpc-405-linux-gnu/gcc-4.1.0-glibc-2.3.6/build-glibc/csu/version-info.h:3:1: missing terminating " character
make[2]: *** [/home/skorpio/crosstool-0.43/build/powerpc-405-linux-gnu/gcc-4.1.0-glibc-2.3.6/build-glibc/csu/version.o] Error 1
make[2]: Leaving directory `/home/skorpio/crosstool-0.43/build/powerpc-405-linux-gnu/gcc-4.1.0-glibc-2.3.6/glibc-2.3.6/csu'
make[1]: *** [csu/subdir_lib] Error 2
make[1]: Leaving directory `/home/skorpio/crosstool-0.43/build/powerpc-405-linux-gnu/gcc-4.1.0-glibc-2.3.6/glibc-2.3.6'
make: *** [lib] Error 2

查看version.h会发现很皈依的语法错误
本来以为是原作者疏忽,我自己手动修改了version.h后重新编译,结果仍然是同样的错误,查看version.h发现回到了我修改前的状态
可以断定该文件是自动生成的
那为什么会这样呢
在网上搜索了大量资料后发现原来是ubuntu这家伙搞的鬼

In Ubuntu 6.10, the default system shell, /bin/sh, was changed to dash (the Debian Almquist Shell); previously it had been bash (the GNU Bourne-Again Shell). The same change will affect users of Ubuntu 6.06 LTS upgrading directly to Ubuntu 8.04 LTS. This document explains this change and what you should do if you encounter problems.

The default login shell remains bash.

(From UBUNTU WIKI https://wiki.ubuntu.com/DashAsBinSh)

为了确认你可以在命令行下执行
echo $SHELL
或者
ls -la /bin/sh
若是bash则没问题,若是dash就需要做更正

为了修正该问题,按照WIKI上的“指示”修改了demo-arm-softfloat.sh里的第一行

#! /bin/sh
改成了
#! /bin/bash
又经过十几分钟的编译,还是失败

于是决定用暴利办法:
sudo mv /bin/sh /bin/sh.old
sudo ln -sf bash /bin/sh

重新启动shell经过漫长的等待,最后生成新的crosstool chains。修改U-BOOT的Makefile文件,指定cross tool。
make distclean
make smdk2410_config
make all
终于可以编译成功了。

相关内容