Building gcc for solaris on sparc64 from linux on x86
Wed Nov 1 10:12:00 GMT 2006
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
- gcc main.c returns:
error: sys/isa_defs.h: No such file or directory
- gcc -I/usr/include main.c returns :
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
- gcc -v -I/usr/include main.c returns:
-V -Y P,/usr/ccs/lib:/usr/lib -rpath-link
/var/tmp//cckBXSUx.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh -lc
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).
For unsubscribe information see http://sourceware.org/lists.html#faq
More information about the crossgcc