This is the mail archive of the gcc-help@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]

RE: Cross Compiler


Antonio Catani wrotes:

> Sparc system is so slow to compile kernel, so, my ix86 system is to
> fast, for this i would like build a cross compiler from ix86 linux
> system to sparc system.

I haven't had much luck building cross-compilers for sparc-linux (at
least from solaris), but here's the process: you need binutils and GCC
distributions, plus sparc-linux system includes and libraries. It sounds
like you already have a working sparc-linux system so you can just take
the last two from that: otherwise, you'll need to generate them from
glibc and the linux kernel source.

1. Copy the contents of /lib (but not subdirectories) and /usr/lib (but
not subdirectories) from your sparc-linux machine to a directory your
build machine.
2. Copy the whole /usr/include tree from your sparc-linux machine to a
directory on your build machine. Make sure you copy the contents of
/usr/include/asm and /usr/include/linux rather than just the symlinks!
3. Uncompress binutils and gcc into the same source tree. Whichever one
has the more recent include and libiberty files should take precedence.
You can do this a number of ways, including combining separate trees
using find and cpio (see http://gcc.gnu.org/simtest-howto.html) or just
untar them both into the same directory using symlinks, e.g.:

    fox:~/src$ mkdir toolchain
    fox:~/src$ ln -s toolchain binutils-2.11.2
    fox:~/src$ ln -s toolchain gcc-3.02
    fox:~/src$ bzip2 -cd binutils-2.11.2.tar.bz2 |tar xvf -
    fox:~/src$ bzip2 -cd gcc-3.02.tar.bz2 |tar xvf -

4. In an empty build directory, configure, build and install the
toolchain, e.g.:

    fox:~/build/sparc-linux$ ~/src/toolchain/configure \
    --prefix=<wherever> \
    --with-headers=<path to sparc-linux /usr/include copy> \
    --with-libs=<path to sparc-linux /lib copy> \
    --with-libs=<path to sparc-linux /usr/lib copy> \
    --enable-languages=c \
    --target=sparc-linux && make && make install

(I don't think you need C++ for the kernel, do you?) Beware that the
configure and install steps above will attempt to write to the prefix
tree, so you'll need appropriate permissions (or set prefix to a subdir
of your home directory.)

You now might have 'sparc-linux-gcc' and friends, so you can edit the
kernel makefile:

    ARCH=sparc
    CROSS-COMPILE=sparc-linux-

However, my build falls over because (I think) of a specs error: the new
sparc-linux linker tries to link in /lib/ld-linux.so even though this
belogs to the build system and not the target system. I'm no specs
wizard and I haven't had time to come up with a correct fix for this
yet. Hacking around that, the kernel build falls over because
'task_struct' doesn't seem to be defined, and I know even less about the
kernel sources to try and fix that one.

Good luck,
Rup.


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