compiling gcc for multiple targets?

Bernd Jendrissek berndj@prism.co.za
Thu Apr 1 06:40:00 GMT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Mar 31, 2004 at 09:46:30AM -0600, Ken Wolcott wrote:
> On Tue, 2004-03-30 at 17:20, Carl B. Constantine wrote:
> > I've done a google search on this, but most of the information I found
> > was old and the crossgcc list no longer exists, so I thought I would
> > bring it up again.

So who's writing all these replies, then?  :)

> > Is there any way to compile gcc and related utils (binutils, gdb) for
> > multiple targets in one binary? So I want to compile it to support both
> > Solaris intel and m68hc11 in one gcc instead of having separate binaries
> > for each?

binutils can be configured with --enable-targets=all, and I use a such
configured binutils daily without problems.  But don't be fooled: it
just configured the BFD and opcodes libraries to *support* all targets
binutils knows; the tools still default to the --target=foo with which
you configured the tools.  And gas (the assembler) cannot generate code
for any other target than the one specified with --target=foo.

GCC supports only one target at a time, but I think if someone wanted to
put in the work, it'd be not-all-that-hard (for a competent hacker) to
make it possible to use multiple backends.  The actual compiler, cc1,
lives in its own target-specific directory, so at a minimum you'd just
need to re-teach the compiler driver (gcc) to find different compilers
again (if it can't still do this - the man page seems to say it can).

More interesting would be if GCC would install a libbackend.so (GPL'ed
and with an undocumented API, of course, to avoid all that
GPL-subversive intermediate-representation stuff) against which a
target-neutral compiler is linked.  And if you watch your namespaces
properly, and hookify  all the target macros, you might get a
libbackend.so that can be configured with --enable-targets=all.

> > If I cannot do this, but have to compile separate versions
> > (--program-prefix=m6811-elf) are there any issues wrt to libraries if
> > they are installed to the same place? libiberty.so for example?

I have binutils configured with --enable-targets=all, and the resulting
libbfd.so and libopcodes.so live in /usr/lib.  I use it daily.

Hmm, no, you'd have to install target libraries (libiberty.{a,so}) to
different places.

- -- 
"IBM has more patent litigation lawyers than SCO has employees." - unknown
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFAa7gb/FmLrNfLpjMRAqWBAJ4s9TJnc1rq7byIWMpl42lSuoIsIACgknmk
OexGgbdiG4+flo1CJk+JUeI=
=1lzi
-----END PGP SIGNATURE-----



More information about the Gcc-help mailing list