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]
Other format: [Raw text]

cross compiling thoughts


Hi All,

For the past 2 days I've been building cross compilers for the i386-unknonw-freebsd5 target to be able to use distcc to rebuild stuff on my freebsd server.
I had to build cross compilers for a SunOS2.9, linux-sparc64 and linux-ppc hosts, and I used the following procedure on each host:


$ su
# mkdir /usr/local/cross
# chown axel /usr/local/cross
# exit
$ setenv D /usr/local/cross/i386-unknown-freebsd5
$ mkdir $D
$ cd
$ mkdir src
$ mkdir src/gcc
$ mkdir src/gcc/build
$ mv binutils.tgz gcc.tgz src/gcc
$ cd src/gcc
$ echo * | xargs -n 1 tar xzf -
$ cd build
$ mkdir binutils; cd binutils
$ ../../configure --prefix=$D --target=i386-unknown-freebsd5
$ make
$ make install

$ tar -C $D -xzf ~/freebsd5-includes.tgz
$ tar -C $D/i386-unknown-freebsd5 ~/freebsd5-libs-small.tgz

$ cd ..; mkdir gcc && cd gcc
$ ../../configure --prefix=$d --target=i386-unknown-freebsd5 --disable-shared --enable-languages=c,c++
$ make
$ make install


The freebsd5-libs-small.tgz contains only the following libs:
/usr/lib/crt*
/usr/lib/libc.a

while the includes package is an archive of /usr/include.

The above procedure produces a nice set of cross compiling tools to build c and c++ sources. But... I was wondering if this was the right way to do it; This time I could easily get the needed includes and libs from the freebsd target host, but what if I wanted to use a platform which I didn't have access too?

I'd imagine I could build glibc with a somewhat minimal c compiler configured as follows;
$ cd src/gcc/build/gcc
$ rm -rf *
$ ../../gcc/configure --prefix=$D --target=i386-unknown-freebsd5 --disable-shared --enable-languages=c
$ make && make install
$ cd ..; mkdir glibc && cd glibc
$ ../../glibc/configure --prefix=$D --target=i386-unknown-freebsd5
$ make && make install
$ cd ../gcc
$ rm -rf *
$ ../../gcc/configure --prefix=$D --target=i386-unknown-freebsd5 --disable-shared --enable-languages=c,c++
$ make && make install


It's been quite a while since I've done something like this, last time was a couple of years back using an older version of gcc.
This is gcc 3.3.2, and it seems to need a prebuild libc to build itself correctly.


I would have tried that, but it was getting late and my Solaris machine kindly attended me that SunOS2.9 wasn't supported.

I did some googling, and it seems there is also a 'newlib'. Is this compatible with glibc? e.g. Can I cross build files for a host which only has glibc? Never had a look at it, I should.

Considering glibc was supported, and it wasn't about 02:30 in the morning, I could build that, install it and then rebuild gcc with c++ enabled.

Then I still need some header files for the target host..
Should I build a bootstrap compiler first then? (Didn't I do that in my first gcc build above?) With no headers it can't find several freebsd (*bsd) specific stuff, I wonder how I could somehow generate them from something?


I've tried to find a somewhat complete description of the whole procedure, but I couldn't find much regarding these problems.
Can someone enlighten me a bit about it, or hand me some pointers which might be usefull?


I'm not on this list, since I don't know if it's the correct one for cross-gcc questions/matters. If not, please guide me to the right list.

Any help is appreciated.

Note that's not urgent, I have a working set of tools compiled as mentioned above, I'm just a bit curious about the (small) problems I've encountered.

Kind regards,
--
VIA NET.WORKS Nederland

Axel Scheepers
System Administrator UNIX
phone   +31 40 239 33 93
fax     +31 40 239 33 11
e-mail  ascheepers@vianetworks.nl
pgp id  21A33FE0
http://www.vianetworks.nl/


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