Building gcc for solaris on sparc64 from linux on x86

David Cournapeau david@ar.media.kyoto-u.ac.jp
Wed Nov 1 10:12:00 GMT 2006


Hi there,

    I am a newbie at cross-compiling, so please excuse my stupid 
mistakes and/or vague terminology. I have two machines:

    - M1 which runs linux on x86
    - M2 which runs solaris on sparc64.

My goal is the following: having a "native" gcc compiler  on M2, ie a 
compiler which can be run on M2 and which target code for M2. This 
machine does not have a C compiler, so my idea was to compile a cross 
compiler (hosted on M1, targeting M2) first, and then using this 
cross-compiler to build the "native" compiler.

    To build the cross compiler, I followed the instructions there : 
http://gcc.gnu.org/ml/gcc/2004-05/msg01376.html, including the answer. I 
think the cross compiler works, as I could compile a hello world on M1 
running on M2. I also compiled a 'real' package, rsync, with success (ie 
compile on M1 and runs fine on M2).

    Then, I used this toolchain to build on M1 a "native" solaris gcc: I 
used a scheme analog to the cross compiler, except that I set host and 
target to sparc-sun-solaris2.9, and build to i686-pc-gnu. The 
compilation went Ok too, but I cannot make this new compiler work on M2. 
I installed all the programs with the prefix $HOME/solaris/local/ on M2, 
and added $HOME/solaris/local/bin in my PATH. All the following are run 
on M2:

    - gcc main.c returns:
 snip
/export/home/david/solaris/local/bin/../lib/gcc/sparc-sun-solaris2.9/4.0.3/include/sys/feature_tests.h:24:26: 
error: sys/isa_defs.h: No such file or directory
    - gcc -I/usr/include main.c returns :
/export/home/david/solaris/local/bin/../lib/gcc/sparc-sun-solaris2.9/4.0.3/../../../../sparc-sun-solaris2.9/bin/ld: 
values-Xa.o: No such file: No such file or directory
collect2: ld returned 1 exit status

    To get more info, I run gcc with verbose output, and I got the 
following:

    - gcc -v -I/usr/include main.c returns:
snip
 /export/home/david/solaris/local/bin/../libexec/gcc/sparc-sun-solaris2.9/4.0.3/collect2 
-V -Y P,/usr/ccs/lib:/usr/lib -rpath-link 
/usr/media/boulot/src/cross-compile/linux86_to_solaris_sparc/sysroot/usr/lib 
-Qy 
/export/home/david/solaris/local/bin/../lib/gcc/sparc-sun-solaris2.9/4.0.3/crt1.o 
/export/home/david/solaris/local/bin/../lib/gcc/sparc-sun-solaris2.9/4.0.3/crti.o 
values-Xa.o 
/export/home/david/solaris/local/bin/../lib/gcc/sparc-sun-solaris2.9/4.0.3/crtbegin.o 
-L/export/home/david/solaris/local/bin/../lib/gcc/sparc-sun-solaris2.9/4.0.3 
-L/export/home/david/solaris/local/bin/../lib/gcc 
-L/home/david/solaris/local//lib/gcc/sparc-sun-solaris2.9/4.0.3 
-L/export/home/david/solaris/local/bin/../lib/gcc/sparc-sun-solaris2.9/4.0.3/../../../../sparc-sun-solaris2.9/lib 
-L/home/david/solaris/local//lib/gcc/sparc-sun-solaris2.9/4.0.3/../../../../sparc-sun-solaris2.9/lib 
-L/export/home/david/solaris/local/bin/../lib/gcc/sparc-sun-solaris2.9/4.0.3/../../.. 
-L/home/david/solaris/local//lib/gcc/sparc-sun-solaris2.9/4.0.3/../../.. 
/var/tmp//cckBXSUx.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh -lc 
/export/home/david/solaris/local/bin/../lib/gcc/sparc-sun-solaris2.9/4.0.3/crtend.o 
/export/home/david/solaris/local/bin/../lib/gcc/sparc-sun-solaris2.9/4.0.3/crtn.o
snip

    My understanding is that because the file values-Xa.o does not have 
any prefix on it, collect2 cannot finish the link. To confirm this is 
the only problem, I first compiled my main.c using gcc -c -I/usr/include 
main.c, and then run again the collect2 command by hand, prefixing 
correctly the values-Xa.o file and with main.o instead of the tmp file. 
This gave me a correct program which can be run.

    Is this a bug, or a mistake from my configuration somewhere ? Also, 
is there a way to tell the installed native compiler to use the native 
header, libraries and so on, so I don't have to set /usr/include, 
/usr/lib and so on by hand ? (My goal is to be able to compile some 
common open source tools on M2 for M2).

    cheers,

    David


--
For unsubscribe information see http://sourceware.org/lists.html#faq



More information about the crossgcc mailing list