交叉编译时缺少crt1和crti

5

我正在尝试基于启用了gold和链接时优化的GCC4.5和newlib构建交叉编译工具链。GCC编译完好,但没有生成crt1.o或crti.o文件。因此,当我尝试使用编译器构建Newlib时,它会出现以下错误信息:

ld: error: cannot open crti.o: No such file or directory
ld: error: cannot open crtn.o: No such file or directory
ld: error: cannot find -lc

在搜索安装了GCC4.5的目录中名为crt*的文件时,我得到了以下结果:
find ../../../tooltarget/ -name "crt*" -print #(result modified to consume less space)
crtprec80.o, crtend.o, crtfastmath.o, crtbegin.o, crtendS.o, crtprec32.o, crtbeginS.o, crtbeginT.o, crtprec64.o

从GCC规范来看,gcc需要crtbegin.o和crti.o文件,但只有其中一个文件可用。
*startfile:                                       
%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}    crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o
%s;:crtbegin.o%s} 

以下是我在编译GCC时使用的标志:
--prefix=${TTP}/usr         --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu  --target=x86_64-awn-linux-gnu
--with-gmp=${TTP}/usr       --with-mpc=${TTP}/usr
--with-mpfr=${TTP}/usr      --with-libelf=${TTP}/usr               
--enable-languages=c        --enable-lto                           
--disable-nls               --disable-shared                       
--disable-multilib          --disable-decimal-float                
--disable-libmudflap        --disable-libssp                       
--disable-libgomp           --disable-threads                      
--without-headers           --with-newlib                          
--with-build-sysroot=${TTP} --with-build-time-tools=${TTP}/usr/bin 

我不确定这是因为我错误地配置了GCC,还是因为“某些东西”不按照这种方式工作,或者crti.o文件应该从其他地方获取。

提前感谢

Allan W. Nielsen


1
可能是[crti.o文件丢失]的重复问题(https://dev59.com/TnVD5IYBdhLWcg3wGHiu)。 - user2284570
我刚用gcc构建添加了--host=x86_64./configure脚本来解决一个类似的问题,但不确定是否有帮助。 - ton
1个回答

1

一些crt*文件并非来自编译器,而是来自C库。我怀疑你的crt1.ocrti.o也是这种情况。


1
不,有ctr1.S和crti.S,它们是在gcc构建期间由脚本生成的。 - user2284570
事实上,GCC对这些文件使用了一些脚本。我猜大多数人都不太清楚,至少我是不清楚的。 - shevy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接