Chinaunix首页 | 论坛 | 博客
  • 博客访问: 538567
  • 博文数量: 150
  • 博客积分: 5010
  • 博客等级: 大校
  • 技术积分: 1861
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-17 00:19
文章分类

全部博文(150)

文章存档

2011年(1)

2009年(14)

2008年(135)

我的朋友

分类: LINUX

2008-04-11 10:39:28

昨天还没6点就开始做,在下面的一个阶段,make all-gcc 报错:


/home/qing/arm_toolchain/tools/arm-linux/include/asm/unistd.h: Assembler messages:
/home/qing/arm_toolchain/tools/arm-linux/include/asm/unistd.h:4: Error: bad instruction `extern int errno'
make[1]: *** [libgcc1-asm.a] Error 1
make: *** [all-gcc] Error 2

也不知道什么原因,上网查也查不到,实在是能力有限,穷折腾。晚上12点时没弄好,早晨6点40起来,就关疼这个事,到了,现在10:36,又重新从头做了一遍。内核配置还没有完全掌握,
现在终于松了一口气,可以往下做了。但这个错误就浪费了9个多小时,终于体会到开发的不易,以后要踏踏实实的学,专心、专业、专注!!
   再不想共产主义,再不看新闻,电视。好好的学习!!!



=========================
此步骤不需要设置内核头文件!

进入build-tools目录, 下载并到网站下载这三个补丁:

   

解压GCC,并打补丁:
$cd gcc-2.95.3
$patch -p1< ../gcc-patch/gcc-2.95.3-2.patch
$patch -p1< ../gcc-patch/gcc-2.95.3-no_fixinc-1.patch
$patch -p1< ../gcc-patch/gcc-2.95.3-returntype_fix-1.patch
echo timestamp > gcc/cstamp-h.in

如果你用的是Ubuntu默认的gcc(既安装build-essential中的gcc, 该gcc的版本目前是4.0.2). 在编译时候会提示"invalid lvalue in increment"错误. 最好使用gcc-3.3.
Ubuntu中安装gcc-3.3: $ sudo apt-get install gcc-3.3
只有调用不同版本的gcc, 只需:
$ export CC=gcc-3.3

对t-linux文件作一些修改:
-----------------------------
修改$PRJROOT/gcc-2.95.3/gcc/config/arm/t-linux,把
TARGET_LIBGCC2-CFLAGS = -fomit-frame-pointer -fPIC
这一行改为
TARGET_LIBGCC2-CFLAGS = -fomit-frame-pointer -fPIC -Dinhibit_libc -D__gthr_posix_h
注意是arm目录下的!在/gcc/config目录下也有一个t-linux文件,别弄混淆了。
-----------------------------
上面的修改方案来自IBM developerworks上的“如何为嵌入式开发建立交叉编译环境”. 但我在编译过程中老是碰见"libgcc1.S:438: asm/unistd.h: No such file or directory"这样的错误. 原先以为是本地GCC的问题, 用gcc-2.95.3, gcc-3.3等编译, 还是如此. 又以为需要在这里设置内核头文件, 拷贝, 建立符号连接... 什么方法都试过, 还是不行. 我KAO...

实际上, 应该这样修改t-linux:
TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC语句之前添加"T_CFLAGS = -Dinhibit_libc -D__gthr_posix_h"
成为:
T_CFLAGS = -Dinhibit_libc -D__gthr_posix_h
TARGET_LIBGCC2_CFLAGS = -fomit-frame-pointer -fPIC


-Dinhibit_libc等同于在命令中加上"--with-newlib", 它告诉配置工具不要使用glibc, 因为当前的glibc并不是针对目标板的. 从字面上看, 它是告诉配置工具"使用一个新的c库来作为目标板的C链接库. 然而当前我们并没有可用的C链接库, 所以这个选项只是让GCC能够正确编译, 生成一个初始编译器而已. 随后可以选择C链接库.

-D__gthr_posix_h我不知道是什么意思, 反正如果不更改上面的语句, 就会有如下的错误:
../../gcc-2.95.3/gcc/gthr-posix.h:37: pthread.h: No such file or directory
可能是去掉posix thread支持吧.

配置
$ cd $PRJROOT/build-tools/build-boot-gcc/
$ ../gcc-2.95.3/configure --target=$TARGET --prefix=$PREFIX --without-headers --enable-language=c --disable-threads

--target, --prefix 和配置 binutils 的含义是相同的. --without-headers 就是指不需要头文件, 因为是交叉编译工具, 不需要本机上的头文件. --with-newlib在前面已经介绍了, 即便更改了t-linux文件, 也可以在这里设置--with-newlib. -enable-languages=c是指我们的 boot-gcc 只支持 c 语言. --disable-threads 是去掉 thread 功能, 这个功能需要 glibc 的支持.

如果用的比较老版本gcc (比如gcc-2.95.3) 在配置过程中会提示这样的错误:
Config.guess failed to determine the host type.  You need to specify one.
这是由于config.guess, config.sub版本太老. config.guess是用来检测host类型的, 运行它就能得知host类型.
解决方法: 到ftp://ftp.gnu.org/pub/pub/gnu/config/下载新版的config.guess和config.sub:
 *checkout*/config/config/config.guess
*checkout*/config/config/config.sub
用它们替换gcc-2.95.3目录下的老文件.
现在运行 $./config.guess:
i686-pc-linux-gnu

编译, 安装
$ make all-gcc
$ make install-gcc

阅读(3190) | 评论(5) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2009-10-15 11:09:22

改名不好,最好是做一个符号连接。

chinaunix网友2009-03-11 11:50:31

libgcc1.S:438: asm/unistd.h: ????????? make[1]: *** [libgcc1-asm.a] Error 1 make: *** [all-gcc] Error 2 将目标文件夹$TARGET_PREFIX/include/内的asm-linux文件夹更改名称为asm,    因为配置文件的include包含都是方式。这也是交叉编译的不同之处。

chinaunix网友2008-12-23 18:52:42

你好,我现在也在学嵌入式系统,也在安装交叉编译工具,同样的在编译gcc这一步时出现错误,也按照你的方法修改了t-linux,可还是有如下错误: libgcc1.S: Assembler messages: libgcc1.S:75: Warning: ignoring redefinition of register alias 'ip' libgcc1.S:76: Warning: ignoring redefinition of register alias 'sp' libgcc1.S:77: Warning: ignoring redefinition of register alias 'lr' libgcc1.S:78: Warning: ignoring redefinition of register alias 'pc' libgcc1.S: Assembler messages: libgcc1.S:243: Warning: ignoring redefinition of register alias 'ip' libgcc1.S:244: Wa

chinaunix网友2008-12-23 18:52:39

你好,我现在也在学嵌入式系统,也在安装交叉编译工具,同样的在编译gcc这一步时出现错误,也按照你的方法修改了t-linux,可还是有如下错误: libgcc1.S: Assembler messages: libgcc1.S:75: Warning: ignoring redefinition of register alias 'ip' libgcc1.S:76: Warning: ignoring redefinition of register alias 'sp' libgcc1.S:77: Warning: ignoring redefinition of register alias 'lr' libgcc1.S:78: Warning: ignoring redefinition of register alias 'pc' libgcc1.S: Assembler messages: libgcc1.S:243: Warning: ignoring redefinition of register alias 'ip' libgcc1.S:244: Wa

chinaunix网友2008-12-23 18:52:32

你好,我现在也在学嵌入式系统,也在安装交叉编译工具,同样的在编译gcc这一步时出现错误,也按照你的方法修改了t-linux,可还是有如下错误: libgcc1.S: Assembler messages: libgcc1.S:75: Warning: ignoring redefinition of register alias 'ip' libgcc1.S:76: Warning: ignoring redefinition of register alias 'sp' libgcc1.S:77: Warning: ignoring redefinition of register alias 'lr' libgcc1.S:78: Warning: ignoring redefinition of register alias 'pc' libgcc1.S: Assembler messages: libgcc1.S:243: Warning: ignoring redefinition of register alias 'ip' libgcc1.S:244: Wa