5

I'am trying to build a cross compile toolchain based on GCC4.5 and newlib with gold and link-time-optimization enabled. GCC compiles fine but it did not generate the crt1.o or crti.o files. Therefore when I tries to use the compiler for building Newlib it complains with the message:

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

When searching for files named crt* in the directory where GCC4.5 is installed i got the following result:

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

From the GCC spec's it seems like gcc needs both the crtbegin.o and the crti.o files, but only one of them is available.

*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} 

Following is the flags i used when compiling 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 

I'm sure on if this is due to I configured GCC wrongly, or "stuff" simply do not work this way, or if the files crti.o should come from somewhere else.

Thanks in advance

Allan W. Nielsen

Allan
  • 4,562
  • 8
  • 38
  • 59
  • 1
    possible duplicate of [crti.o file missing](http://stackoverflow.com/questions/91576/crti-o-file-missing) – user2284570 Jul 19 '14 at 09:14
  • I just solved a problem like this with gcc build adding `--host=x86_64` to `./configure` script, but not sure if helps. – ton Feb 19 '17 at 00:11

1 Answers1

1

Some crt* files come not from the compiler, but from the C library. I suspect this is the case here for your crt1.o and crti.o.

F'x
  • 12,105
  • 7
  • 71
  • 123
  • 1
    No, there are ctr1.S and crti.S which are generated by a script during gcc's build time. – user2284570 Jul 19 '14 at 09:16
  • Indeed, GCC uses some scripts for these files. It's not very transparent to most people I guess; at the least it is not to me. – shevy Nov 14 '18 at 11:37