为什么 GCC 交叉编译不构建 `crti.o`? [英] Why is a GCC cross compile not building `crti.o`?

查看:31
本文介绍了为什么 GCC 交叉编译不构建 `crti.o`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试为 arm 构建 gcc 4.xx 交叉编译器时,我被困在 $BUILD_DIR/gcc 子目录中丢失的 crti.o 文件中.

In an attempt to build a gcc 4.x.x cross compiler for arm, I'm stuck at a missing crti.o file in the $BUILD_DIR/gcc subdirectory.

顶层Makefilestrace表明编译后的xgcc正在调用交叉链接器ld"crti.o" 作为参数.我假设如果调用了交叉链接 ld,则不需要本机 /usr/lib/crti.o.

An strace on the top level Makefile shows that the compiled xgcc is calling the cross-linker ld with "crti.o" as an argument. I'm assuming that if the cross linking ld is being called, the native /usr/lib/crti.o is not what is needed.

我可以看到在 gcc 源代码树中有许多潜在的 crti 对象来源(包括 $SRC_DIR/gcc/config/arm/crti.asm).

I can see that in the gcc source tree there is a number of potential sources for a crti object (including $SRC_DIR/gcc/config/arm/crti.asm).

如何配置 gcc 构建以确保构建此文件(或从 ld 命令中省略)?

这是我的配置行:

/x-tools/build/gcc-4.5.0$ ../../src/gcc-4.5.0/configure --target=arm-linux --prefix=/opt/arm-tools --disable-threads --enable-languages=c

推荐答案

真正的答案是应该编译crti.o 如果有的话是为了构建 arm-elf 目标. 在构建 arm-linux 目标时,gcc 人合理地假设 glibc 之前已经编译过,它将提供 crti.o 启动.完全合理,如果您要升级.

The real answer is that it should compile crti.o if one was to build an arm-elf target. In building an arm-linux target, the gcc people reasonably assume that glibc has been compiled previously and it will provide the crti.o startup. Perfectly reasonable, if you're upgrading.

构建新的根文件系统是另一回事,这是一个自相矛盾的故事(先出现:glibc 还是 gcc?).一种方法(得到认可,但我还没有成功)是构建一个独立的 gcc(例如,arm-elf\static)然后 glibc,然后再次gcc.

Building a new root file system is another story, a paradoxical one at that (which comes first: glibc or gcc?). An approach (endorsed, but I've not yet succeeded with) is to build a stand-alone gcc (arm-elf\static, say) then glibc, then gcc again.

似乎有些人通过修改 gcc\config\arm\t-linux<解决了 arm-linux 目标中缺失的 crti.o.与其依赖不存在的glibc,不如使用arm-elf 提供的crti.o 版本.可以在此处找到示例.

It seems as though some have addressed the missing crti.o in an arm-linux target by modfiying gcc\config\arm\t-linux. Rather than relying on an unexisting glibc, the kludge is to use the arm-elf provided version of the crti.o. An example can be found here.

--- gcc-3.4.4/gcc/config/arm/t-linux    2003-09-20 17:09:07.000000000 -0400
+++ gcc-3.4.4.works/gcc/config/arm/t-linux  2005-05-25 20:44:07.000000000 -0400
@@ -18,3 +18,24 @@

 # LIBGCC = stmp-multilib
 # INSTALL_LIBGCC = install-multilib
+
+EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crti.o crtn.o
+
+# If EXTRA_MULTILIB_PARTS is not defined above then define EXTRA_PARTS here
+# EXTRA_PARTS = crtbegin.o crtend.o crti.o crtn.o
+
+LIBGCC = stmp-multilib
+INSTALL_LIBGCC = install-multilib
+
+# Assemble startup files.
+$(T)crti.o: $(srcdir)/config/arm/crti.asm $(GCC_PASSES)
+   $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
+   -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/arm/crti.asm
+
+$(T)crtn.o: $(srcdir)/config/arm/crtn.asm $(GCC_PASSES)
+   $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
+   -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/arm/crtn.asm
+
+# Disable libc link
+
+SHLIB_LC =

这篇关于为什么 GCC 交叉编译不构建 `crti.o`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆