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: Workaround: compiling GCC 3.0 as a cross-compiler under Linux


John Zaitseff wrote:

> A number of people have previously queried compiling GCC 3.0 as a
> cross-compiler for embedded systems under Linux.  These people have
> had problems in doing so, with apparently no answers to their
> queries.

Oh. If *I*'d seen the questions, I'd have had a go.

Yes, you need GCC, binutils and newlib, but the easiest way is to build
all three as a single toolchain: the top-level directories of all three
are roughly the same and the top level configure and makefile support
this.

Unpack all three sources to a single tree; I read on the GCC list that
the GCC files should take precedence :-) but if you're combining
packages with radically different timestamps, you need to pay attention
to the libiberty and include directories. I'd recommend allowing the
most recent libiberty and includes to overwrite the older copies (or
even deleting the older copies first and installing the most recent
clean). You can use find / cpio games to hard-link three separate source
trees to a single toolchain tree (recommended if you're using CVS copies
of the packages) but if it's a single untar, build, throw then you might
as well plain overwrite, e.g. symlink for ease:

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

Then you just need a single configure and make step:

    fox:~/build/arm-elf$ ~/src/toolchain/configure \
    --target=arm-elf --prefix=~/local-arm-elf && gmake

and you're away. It'll first build binutils, then gcc and finally newlib
using both the arm-elf binutils and gcc. It does not attempt to install
anything in the target path, as you mention, and all three can be
installed in one go. And that's it - a workable embedded-cross-compiler
with no fuss.

If you want to check the resulting compiler, you can use gdb's sim.
There are instructions on the GCC website:

    http://gcc.gnu.org/simtest-howto.html

although that's based around CVS sources.

> The reason for the world-writable gcc-lib/arm-elf directory (also a
> bad idea) is that GCC's Makefile will copy files there during "make
> all".

I agree that world-writable is a bad idea. However, it'd be easier and
safer to temporarily grant the build user ownership or group privs to
the relevant parts of the install tree. On the other hand, this isn't
needed for the single-toolchain method.

Rup.


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