This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Cross compiling problems with crti.o


I'm currently working on normal x86 support in the x86-64 compiler tree. I 
have a problem that has been discussed before here, but I couldn't find any 
answers telling me what to do. Andreas Jaegers question is 
http://gcc.gnu.org/ml/gcc-bugs/2000-09/msg00093.html.

My problem is that x86-64 needs the exact same setup where one compiler has 
to be able to generate code for the 32 and 64 bit architectures. This is 
being done for so many architectures now, that this problem must have been 
solved.

I copied the STARTFILE_SPEC and ENDFILE_SPEC from sparc, and ended up with 
being unable to compile a working gcc :-( When --enable-shared is used, the 
compiler won't build because the linker can't find the 64 bit crti.o when 
linking libgcc_s.so. If --disable-shared is used, the compiler can build and 
install, but compiling an empty main produces:

bo@pluto /work/tmp> x86_64-unknown-linux-gcc -v hmm.c
Reading specs from /opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1/specs
Configured with: ../gcc/configure --target=x86_64-unknown-linux 
--prefix=/opt/x86-64 --enable-languages=c --enable-threads=posix 
--enable-debug --disable-sharedThread model: posix
gcc version 3.1 20010430 (experimental)
 /opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1/cc1 -lang-c -v -D__GNUC__=3 
-D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ 
-D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__STDC_HOSTED__=1 
-Acpu=x86_64 -Amachine=x86_64 -D__x86_64 -D__x86_64__ 
-D__SIZE_TYPE__=unsigned long int -D__PTRDIFF_TYPE__=long int -D__tune_i386__ 
-D__LONG_MAX__=9223372036854775807L hmm.c -quiet -dumpbase hmm.c -version -o 
/tmp/cctDWQeI.s
GNU CPP version 3.1 20010430 (experimental) (cpplib) (x86_64 Linux/ELF)
GNU C version 3.1 20010430 (experimental) (x86_64-unknown-linux)
        compiled by GNU C version 2.95.3 20010315 (SuSE).
ignoring nonexistent directory "/opt/x86-64/x86_64-unknown-linux/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1/include
 /opt/x86-64/x86_64-unknown-linux/include
End of search list.
 /opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1/../../../../x86_64-unknown-l
inux/bin/as -V -Qy -o /tmp/cc20XmAi.o /tmp/cctDWQeI.s
GNU assembler version 2.11.90 (x86_64-unknown-linux) using BFD version 2.11.90
 /opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1/collect2 -m elf_x86_64 
-dynamic-linker /lib/ld64.so.1 /usr/lib64/crt1.o /usr/lib64/crti.o 
/opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1/crtbegin.o 
-L/opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1 
-L/opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1/../../../../x86_64-unknown-linux/lib 
/tmp/cc20XmAi.o -lgcc -lc -lgcc 
/opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1/crtend.o /usr/lib64/crtn.o
/opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1/../../../../x86_64-unknown-linux/bin/ld: 
cannot open /usr/lib64/crt1.o: No such file or directory
collect2: ld returned 1 exit status

ld is obviously right here, as crt1.o is located in 
/opt/x86-64/x86_64-unknown-linux/lib/crt1.o. Actually it should be placed in 
/opt/x86-64/x86_64-unknown-linux/lib64/crt1.o and .../lib/crt1.o should be a 
x86 version of it but I can't figure out how to do this. So, how can I make 
gcc produce and look in the right places for the 32 and 64 bit crt1?

There's something here I haven't realized yet so I would really be grateful 
if someone can enlighten me.

Just for the record, here are the two macros:

#define STARTFILE_SPEC \
  "%{m32:%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
		    %{!p:%{profile:gcrt1.o%s} %{!profile:crt1.o%s}}}} \
     crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}} \
   %{!m32:%{!shared: %{pg:/usr/lib64/gcrt1.o%s} \
		     %{!pg:%{p:/usr/lib64/gcrt1.o%s} \
		     %{!p:%{profile:/usr/lib64/gcrt1.o%s} \
		     %{!profile:/usr/lib64/crt1.o%s}}}} \
     /usr/lib64/crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"

#define ENDFILE_SPEC \
  "%{m32:%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s} \
   %{!m32:%{!shared:crtend.o%s} %{shared:crtendS.o%s} /usr/lib64/crtn.o%s}"

I have added very preliminary multilib support with a t-linux64 (and added 
this to config.gcc's tmake_file), if these are insufficient, I'd like to hear 
about it:

MULTILIB_OPTIONS = m64/m32
MULTILIB_DIRNAMES = 64 32

LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib

EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o crtbeginS.o crtendS.o

Bo.

-- 

     Bo Thorsen                 |   28 Merton Road
     Free software developer    |   Slough, SL1 1QW
     SuSE Labs                  |   England


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]