[gnu.gcc] Gcc as a cross-compiler

jkp@SAUNA.HUT.FI (Jyrki Kuoppala) (07/28/89)

I've been using gcc and gas as a cross-compiler hosted on a Sparc and
targetting for the m68k and vax architectures.  Things seem to work
pretty smoothly; the GNU linker ld still needs work to make it work in
a cross-compilation environment, but GCC and GAS apparently do an
excellent job.

A couple of minor bugs that bit me:

- gcc (version 1.35.95) complains about the '-bprefix' switch even though
  it's documented.  Also, it seems to drop the -O switch if -b is used;
  I didn't check this thoroughly, I just stopped using -b.
- LINK_SPEC is defined in the xm file xm-sunos4.h.  I think this is
  incorrect. Gcc produces object files for the target architecture, so
  also the linker should be given the options which the target machine
  requires.  LINK_SPEC should be moved to the tm.h file.


In the gcc documentation, there's a comment about the macros
REAL_VALUE_TYPE, REAL_VALUES_EQUAL (X, Y), REAL_VALUES_LESS (X, Y),
REAL_VALUE_LDEXP (X, SCALE) and REAL_VALUE_ATOF (STRING) which should be
defined if gcc is targetting to a machine with a different floating
point hardware.  Is there a reason why could not be used always ?  I
wouldn't think it would performance that much to use them always, and
it would make gcc able to generate code for any target machine running
on any host machine.

Gas already does an excellent job of handling floating-point numbers
in a machine-independent way.  It also seems to have most of the code
needed to implement the macros required by gcc, so that stuff could
probably be merged to gcc.  I think it should be possible to write the
macros so that no parametres to the tm.h needs to be added;
hard-params in the gcc 1.35.95 seems to provide all the needed
information.

If you are interested in that kind of portability improvement and it
isn't being done already, I could do some work on it.

//Jyrki

ham@Polya.Stanford.EDU (Peter R. Ham) (07/28/89)

Personally, I would like to be able to use gcc as a cross
compiler.  Specifically, I'd like to run gcc on a pmax and
produce code for vaxen and m68k's.

The only obstacles that I have seen to this are a call to
atof in gcc that assumes that the target floating point is the
same as the host floating point, the standard gcc makefile makes
a bunch of little "gen*" programs that assume that the host 
and target are the same machine.

In gas, the code that handles floating point numbers in a machine
independent way seemed to fail on our machines which are m68k's with
a floating point library that emulates the floating point of vaxen,
but with bytes swapped. Maybe I just configured this wrong.

I would be interested in hearing more specifics about how people 
have turned gcc into a cross compiler.
--
Peter Ham			PO Box 3430	(h)(415) 324-9645
MS Computer Science Student	Stanford, CA	ham@polya.stanford.edu
Stanford University 		94309		(o)(415) 723-2513