MIPS cross-compilers on Solaris and Linux hosts generate slightly different code

Kai Ruottu karuottu@mbnet.fi
Fri Jan 13 13:56:00 GMT 2006


Barry Wealand wrote:

> Hello -
>
> We're using GCC 4.0.0, with binutils 2.15, both configured and built 
> for a mips-elf target, and hosted on both Solaris and Linux host 
> machines.  All tools are configured and built identically on both 
> hosts.  I then use the tools to build and install newlib-1.13.0, also 
> configured an built identically on both hosts.

Hmmm, I could expect the $build platform being the same for all the 
hosts one could need... Not so many have both Solaris and Linux machines 
on their tables, only one platform
on which to build everything... That a Linux-user has Sparc/Solarix2.x 
and x86/Solaris2.x crosstoolchains installed and then can produce tools 
for these too, shouldn't be that
rare when the Solaris2.x stuff for the latest versions is freely 
available...

Your 'identically' doesn't sound such for me... The tools used in the 
hosts can generate different results. It is not GCC, binutils, ld etc. 
GNU tools but also tools like 'yacc' or
'bison', 'flex', 'sed' which  are different and could even produce 
different source files for the GCC being built.

>   And yet the generated (MIPS) libraries have subtle differences.  For 
> example, I notice different register usage and instruction sequencing 
> in the code generated for the _calloc_r newlib function.  I suspect 
> that both generated sequences are correct, but I have this intuitive 
> expectation that they should be identical (for some reason).  Am I wrong?

 My thought is similar, the results made from just the same sources 
should be identical...

 That you cared to build newlib twice is of course somehow unexpected, 
doing it once with either GCC should be enough for most... But which one 
could be more reliable...

> I noticed just now that the native gcc's, used to build the 
> cross-toolchains, are version 3.2.2 on the Solaris machine and version 
> 3.2 on the Linux machine.  Does this make a difference?

 I would suspect the other tools which are producing sources. Also all 
kind of 'gen*' executables running on the $build platform and handling 
the '*.md' files could behave differently
and produce different results, source files which then will be compiled 
with the $host compiler (3.2.2 or 3.2 in your case).

 When doing everything on one $build system (Linux/x86), I could 
recommend this approach... Not too many different inputs for the build 
process.



More information about the Gcc-help mailing list