Why is a GCC cross compile not building `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.
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 bu开发者_StackOverflow社区ilt (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 =
精彩评论