<!doctype linuxdoc system>
<article>
<title>NetWinder Compiler Notes
<author>Scott Bambrough, <tt>scottb@netwinder.org</tt>
<date>$Revision: 1.1.1.1 $, $Date: 1999/11/02 15:25:12 $

<abstract>
This document describes the GNU Compiler Collection used on the NetWinder.
</abstract>

<toc>

<sect>The GNU Compiler Collection<p>

<sect1>Introduction<p>

The current compiler released for the NetWinder is based on GCC 2.95.1. 
The current build includes patches for ARM ELF from Phil Blundell, Richard
Earnshaw and Rebel.com.

All patches have been submitted for inclusion into the GCC source
tree, and are currently awaiting evaluation.

<sect1>Known bugs.<p>

1) Problem: Internal compiler error: unrecognizable instruction when building
sendmail.

A description of the problem may be found at:

<url url="http://egcs.cygnus.com/ml/gcc-bugs/1999-09/msg00023.html">.

2) Problem: Unrecognizable instruction building mod_php-3.0.3.  

A description of the problem may be found at:

<url url="http://egcs.cygnus.com/ml/gcc-bugs/1999-10/msg00075.html">.

An analysis of this problem can be found at:

<url url="http://egcs.cygnus.com/ml/gcc-bugs/1999-10/msg00097.html">.

This seems to be similar to problem 1.

3) Problem: GCC appears to hang while compiling the following:

<tscreen><code>
int main(int argc, char **argv)
{
  unsigned long u;
  u = 1;
  u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
  u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
  u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
  u += u; u += u; u += u; u += u; u += u; u += u; u += u; u += u;
  if (!u) _exit (0);
  _exit (1);
}
</code></tscreen>

A description and analysis of the problem can be found by following the
mailing list thread that begins here:

<url url="http://egcs.cygnus.com/ml/gcc-bugs/1999-06/msg00853.html">.

4) Problem: Internal error: insn does not satisfy constraints when building
QT 1.42.

A description of the problem may be found at:

<url url="http://egcs.cygnus.com/ml/gcc-bugs/1999-10/msg00078.html">.<p>

I received confirmation that a fix for this had been applied to the mainline 
sources on October 13, 1999.  I have yet to try the patch on GCC 2.95.1, and
it is not in the current RPM release.

5) Problem: Internal error: Multiply not satisfying constraints.

A description, analysis and patches may be found by following the mailing 
list thread that begins here.

<url url="http://egcs.cygnus.com/ml/gcc-bugs/1999-09/msg00040.html">.

This is similar to problem three, and patches have been generated.  They are
being reviewed and should make it into the the mainline code.  Whether they
get placed in the 2.95 branch is doubtful.  I will consider applying the 
patches to GCC 2.95.1 and including them in the RPM's Rebel.com distributes.
The current RPM's do not have these patches included.

6) Problem: Internal compiler error: unrecognizable instruction when building
sendmail.

A description of the problem may be found here:

<url url="http://egcs.cygnus.com/ml/gcc-bugs/1999-09/msg00023.html">.

7) Problem: Routine NewGrab at line 129 in source file
xc/lib/Xt/PassivGrab.c from the XFree86-3.3.3.1 distribution is compiled
incorrectly.  Specifically the parameter widget does not get assigned to
grab->widget correctly.  The pointer is corrupt and a segmentation fault
occurs.

Andrew has determined a work around for this problem and has included it as
a patch in the latest X RPM.
 
8) Problem: Objective C is broken.  I don't have the details at hand.

9) Problem: Java compiler is inoperative.  Requires a port of libgcj in
order to be functional.  This has been started but is on hold while I await
bugfixes in the mainstream compiler.  I received confirmation on October 20,
1999 that the bugs had been fixed in the mainline CVS tree, and that I should
now be able to bootstrap the compiler.  I am currently testing this.

10) Problem: Error: Can not represent OFFSET_IMM relocation in this object
file format when building mgetty.

A description can be found at:

 <url url="http://egcs.cygnus.com/ml/gcc-bugs/1999-10/msg00078.html">.

This seems to be a different problem than the one described below.  

There is a similar code generation bug that crops up when generating constants
when optimization is turned on. The error message that is generated
follows.

<tscreen><verb>
testglib.s:6949: Error: Can not represent OFFSET_IMM relocation in 
this object file format (1) 
</verb></tscreen>

The problem is a local label (.LC164 in this case) that is referenced,
but never defined in the compiler output anywhere.  This label only appears
in the rtl output in the <tt>.greg</tt> file after the reload phase.<p>

The "C" code defines the following long long variable:

<tscreen><verb>
__extension__ typedef unsigned long long guint64; 
guint64 gu64t1 = (__extension__ (0x1d636b02300a7aa7ULL));
</verb></tscreen>

At line 869 in the "C" code it loads this value, ands it with the long
long value 0xff and then shifts the result right by 56 bits.

The problem is in the ARM specific constant-reloading pass which runs as
part of the machine dependent reorganization pass right at the end, before
the final assembly is emitted. This pass contains too many assumptions, and
the example breaks another of them (in this case, the broken assumption is
that a constant needing reloading will always be a simple mov insn). To fix
this requires a rewrite of the constant reloading pass.

This bug was reported to the GCC maintainers, where it was determined a 
rewrite of the constant reloading pass was required.  This rewrite is 
complete, and it is checked into the mainline GCC source.  Unfortunately,
the changes are too extensive to be considered a bug fix for the purpose 
of having it added to the GCC 2.95 branch.

Jim Studt proposed a patch to the arm.md file that prevents the problem
from occurring.  Richard Earnshaw has added a similar patch to the GCC
2.95.1 branch.  This prevents the problem from occurring but does not fix
the root cause.

<sect>Miscellaneous<p>

<sect1>Author<p>

The author and maintainer of the NetWinder Compiler Notes is Scott
Bambrough (scottb@netwinder.org).  Please send any comments, additions, or
corrections so they can be included in the next release.  The latest version of
this document may be obtained from <url
url="http://www.netwinder.org/~scottb/notes/Compiler-Notes.html">.

<sect1>History<p>

The first public release of this document was as an html web page.

October 21, 1999 (version 1.0): Converted web page to SGML, and updated
the content.

<sect1>Copyright Notice<p>

This document is copyright (c) Scott Bambrough, 1999.

Permission is granted to make and distribute verbatim copies of this
document.  The copyright notice and this permission notice must be preserved
on all copies.

</article>

