为什么一个GCC交叉编译没有建立`crti.o`? [英] Why is a GCC cross compile not building `crti.o`?
问题描述
在试图建立手臂GCC 4.xx的交叉编译器,我被困在一个缺少 crti.o
文件中的 $ BUILD_DIR / GCC
子目录中。
这是 strace的
在顶层的Makefile
显示,编译 xgcc
呼吁交联剂 LD
与crti.o
作为参数。我假设,如果交联 LD
被调用,本机 /usr/lib/crti.o
是不是需要什么。
我可以看到,在gcc的源代码树有一些为CRTI对象 $ SRC_DIR / GCC /配置/ ARM / crti.asm
的潜在来源(包括)。
如何配置了gcc编译,以确保该文件是建立(或者从 LD
命令中省略)?的
下面是我的配置行:
/x-tools/build/gcc-4.5.0$ ../../src/gcc-4.5.0/configure --target =臂的Linux - preFIX =的/ opt / ARM工具--disable线程--enable-语言= C
真正的答案是,它的应的编译 crti.o
的如果一个,就是打造一个手臂精灵的目标。的在建设的 ARM-Linux的的目标时,的的gcc 的人合理地假设那的的glibc 的已编译previously,它会提供 crti.o
启动。完全合理的,如果您要升级的 的。
建立一个新的根文件系统是另一个故事,在一个矛盾的一(这是第一位的的glibc 或的gcc 的?)。一种方法(赞同,但我尚未与成功)是建立一个独立的的gcc 的( ARM精灵的\\静态的,假设),那么的的glibc 的,然后的的gcc 的一次。
这好像有些已经解决了缺少 crti.o
在 ARM-Linux的的由modfiying目标 GCC \\ CONFIG \\ ARM \\ T-linux的
。而不是依靠一个unexisting的的glibc 的时,杂牌组装电脑是使用的 ARM精灵的提供的版本 crti.o
。一个例子可以在这里找到 。
--- GCC-3.4.4 / GCC /配置/ 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 =安装支持multilib
+
+ EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crti.o crtn.o
+
+#如果EXTRA_MULTILIB_PARTS没有在上面定义,那么在这里定义EXTRA_PARTS
+#EXTRA_PARTS = crtbegin.o crtend.o crti.o crtn.o
+
+ libgcc的STMP = - multilib的
+ INSTALL_LIBGCC =安装支持multilib
+
+#组装启动文件。
+ $(T)crti.o:$(SRCDIR)/config/arm/crti.asm $(GCC_PASSES)
+ $(GCC_FOR_TARGET)$(GCC_CFLAGS)$(MULTILIB_CFLAGS)$(含)\\
+ -c -o $(T)crti.o -x汇编与 - CPP $(SRCDIR)/config/arm/crti.asm
+
+ $(T)crtn.o:$(SRCDIR)/config/arm/crtn.asm $(GCC_PASSES)
+ $(GCC_FOR_TARGET)$(GCC_CFLAGS)$(MULTILIB_CFLAGS)$(含)\\
+ -c -o $(T)crtn.o -x汇编与 - CPP $(SRCDIR)/config/arm/crtn.asm
+
+#关闭的libc链接
+
+ SHLIB_LC =
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.
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.
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
).
How can I configure the gcc build to insure this file is built (or omitted from the ld
command)?
Here is my configure line:
/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
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.
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.
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屋!