linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* gcc-2.95 broken on PPC?
@ 2003-04-10 12:56 mikpe
  2003-04-10 14:20 ` Benjamin Herrenschmidt
  2003-04-10 14:42 ` Wolfgang Denk
  0 siblings, 2 replies; 10+ messages in thread
From: mikpe @ 2003-04-10 12:56 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-kernel

It seems gcc-2.95, specifically 2.95.4 as included in YDL2.3,
generates incorrect code for recent 2.4 standard kernels on PPC.

Background: Boot floppies made with 2.2 kernels work on my PM4400,
but ones made from recent standard 2.4 kernels fail with a CLAIM error
just after OF has loaded vmlinux.coff. To debug this, I've been slowly
moving forwards from older to newer kernels, making patches at each
point a new kernel version broke vmlinux.coff.

For the latest standard kernel, 2.4.21-pre7, I need three distinct
patches to make vmlinux.coff boot correctly. They are:

1. 2.4.19-pre4 changed arch/ppc/boot/zlib.c in what appears to be a
   reversal to an older version, causing a CLAIM error at the boot
   "clearing .bss" line; my patch reverts that change (but see below)
2. starting with 2.4.20, I get a CLAIM error at the "loading .data"
   line; a well-known patch posted to linuxppc-dev fixed that
   (change arch/ppc/boot/ld.script .data ALIGN(8) to ALIGN(4096))
3. 2.4.21-pre6 changed include/asm-ppc/div64.h to use long long
   arithmetic, again causing a CLAIM error at the "clearing .bss" line;
   my patch reverts that change (but see below)

However, bugs #1 (zlib.c) and #3 (div64.h) disappear if I compile
my kernels with gcc-3.2.2 instead of 2.95.4, which is a strong
indication that 2.95.4 is broken on PPC. Is this something that's
well-known to PPC people?

The patches are included below for reference.

/Mikael

--- linux-2.4.21-pre7/arch/ppc/boot/lib/zlib.c.~1~	Wed Apr  9 10:32:51 2003
+++ linux-2.4.21-pre7/arch/ppc/boot/lib/zlib.c	Wed Apr  9 10:39:41 2003
@@ -925,10 +925,7 @@
       {
         r = t;
         if (r == Z_DATA_ERROR)
-	{
-          ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt));
           s->mode = BADB;
-	}
         LEAVE
       }
       s->sub.trees.index = 0;
@@ -964,7 +961,6 @@
           if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
               (c == 16 && i < 1))
           {
-            ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt));
             s->mode = BADB;
             z->msg = "invalid bit length repeat";
             r = Z_DATA_ERROR;
@@ -992,10 +988,7 @@
         if (t != Z_OK)
         {
           if (t == (uInt)Z_DATA_ERROR)
-	  {
-            ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt));
             s->mode = BADB;
-	  }
           r = t;
           LEAVE
         }
--- linux-2.4.21-pre7/arch/ppc/boot/ld.script.~1~	Sat Nov 30 17:12:23 2002
+++ linux-2.4.21-pre7/arch/ppc/boot/ld.script	Wed Apr  9 10:38:43 2003
@@ -39,7 +39,7 @@
   PROVIDE (etext = .);
 
   /* Read-write section, merged into data segment: */
-  . = ALIGN(8);
+  . = ALIGN(4096);
   .data    :
   {
     *(.data)
--- linux-2.4.21-pre7/include/asm-ppc/div64.h.~1~	Wed Apr  9 10:34:58 2003
+++ linux-2.4.21-pre7/include/asm-ppc/div64.h	Wed Apr  9 10:38:11 2003
@@ -1,23 +1,10 @@
 #ifndef __PPC_DIV64
 #define __PPC_DIV64
 
-#include <linux/types.h>
-
-extern u32 __div64_32(u64 *dividend, u32 div);
-
-#define do_div(n, div)	({			\
-	u64 __n = (n);				\
-	u32 __d = (div);			\
-	u32 __q, __r;				\
-	if ((__n >> 32) == 0) {			\
-		__q = (u32)__n / __d;		\
-		__r = (u32)__n - __q * __d;	\
-		(n) = __q;			\
-	} else {				\
-		__r = __div64_32(&__n, __d);	\
-		(n) = __n;			\
-	}					\
-	__r;					\
-})
+#define do_div(n,base) ({ \
+int __res; \
+__res = ((unsigned long) n) % (unsigned) base; \
+n = ((unsigned long) n) / (unsigned) base; \
+__res; })
 
 #endif

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc-2.95 broken on PPC?
  2003-04-10 12:56 gcc-2.95 broken on PPC? mikpe
@ 2003-04-10 14:20 ` Benjamin Herrenschmidt
  2003-04-10 14:42 ` Wolfgang Denk
  1 sibling, 0 replies; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2003-04-10 14:20 UTC (permalink / raw)
  To: mikpe; +Cc: linuxppc-dev, linux-kernel

On Thu, 2003-04-10 at 14:56, mikpe@csd.uu.se wrote:

> However, bugs #1 (zlib.c) and #3 (div64.h) disappear if I compile
> my kernels with gcc-3.2.2 instead of 2.95.4, which is a strong
> indication that 2.95.4 is broken on PPC. Is this something that's
> well-known to PPC people?
> 
> The patches are included below for reference.

It would be interesting to see the section dumps of the resulting
coff image and compare the version that works and the one that
doesn't. I still suspect some alignement crap, seeing this may
eventually show it.

Ben.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc-2.95 broken on PPC?
  2003-04-10 12:56 gcc-2.95 broken on PPC? mikpe
  2003-04-10 14:20 ` Benjamin Herrenschmidt
@ 2003-04-10 14:42 ` Wolfgang Denk
  1 sibling, 0 replies; 10+ messages in thread
From: Wolfgang Denk @ 2003-04-10 14:42 UTC (permalink / raw)
  To: mikpe; +Cc: linuxppc-dev, linux-kernel

In message <200304101256.h3ACuSw3022796@harpo.it.uu.se> you wrote:
> 
> It seems gcc-2.95, specifically 2.95.4 as included in YDL2.3,
> generates incorrect code for recent 2.4 standard kernels on PPC.

Ummm.. do you have any direct evidence, i. e. a source file where the
generated object code is obviously wrong?

> However, bugs #1 (zlib.c) and #3 (div64.h) disappear if I compile
> my kernels with gcc-3.2.2 instead of 2.95.4, which is a strong
> indication that 2.95.4 is broken on PPC. Is this something that's

This is speculation only. We use gcc-2.95.4 as part of  our  ELDK  in
all  of our projects, and a lot of people are using these tools, too.
We definitely see more problems with gcc-3.x compilers.


Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd@denx.de
Overflow on /dev/null, please empty the bit bucket.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc-2.95 broken on PPC?
  2003-04-12 15:36 Dan Kegel
@ 2003-04-12 19:12 ` Peter Barada
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Barada @ 2003-04-12 19:12 UTC (permalink / raw)
  To: dank; +Cc: linux-kernel, crossgcc


> > The down side is that creating cross compilers from gcc 3.x is a lot
> > harder unless you already have a cross compiled glibc from gcc 2.95.x
> > in the proper paths.
>
>Yep.  I'm not looking forward to dealing with that.  Shame the gcc
>team keeps making building cross compilers harder.

It isn't that hard to build a cross compiler straight from the 3.x
sources; just takes an extra pass.  I've had pretty good luck building
m68k-linux and ppc-linux cross C/C++ compilers from the sources, all I
needed to do was to build a boostrap C compiler that is used to build
glibc, and then come back and build a full up C/C++ compiler.  Check
out the build script from Bill Gatliff's site:

<http://crossgcc.billgatliff.com/build-crossgcc.sh>

-- 
Peter Barada
peter@baradas.org

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc-2.95 broken on PPC?
@ 2003-04-12 15:36 Dan Kegel
  2003-04-12 19:12 ` Peter Barada
  0 siblings, 1 reply; 10+ messages in thread
From: Dan Kegel @ 2003-04-12 15:36 UTC (permalink / raw)
  To: Linux Kernel Mailing List, crossgcc

A high white horse souse wrote:
 > I wouldn't switch to gcc-3.3 for now, the gcc mailing list looks like it
 > has more problems and less features than the unstable bleeding edge
 > gcc-3.4 CVS version.  I am using gcc 3.2.2 for everything.  I compiled
 > my X, my libc, my kernel, my KDE.  That is the first 3.x version that
 > didn't produce incorrect code for any of these.

Thanks for the info.  I feel a lot better about trying gcc-3.2.2 now.
Does anyone know if it needs patches to produce a working kernel
and glibc on sh4?  gcc-3.0.4 needed a sizable patch on sh4, I seem to recall,
but not on ppc.

 > The down side is that creating cross compilers from gcc 3.x is a lot
 > harder unless you already have a cross compiled glibc from gcc 2.95.x
 > in the proper paths.

Yep.  I'm not looking forward to dealing with that.  Shame the gcc
team keeps making building cross compilers harder.
- Dan

-- 
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc-2.95 broken on PPC?
@ 2003-04-11 15:01 mikpe
  0 siblings, 0 replies; 10+ messages in thread
From: mikpe @ 2003-04-11 15:01 UTC (permalink / raw)
  To: benh; +Cc: linux-kernel, linuxppc-dev

On 10 Apr 2003 16:20:55 +0200, Benjamin Herrenschmidt wrote:
> On Thu, 2003-04-10 at 14:56, mikpe@csd.uu.se wrote:
> 
> > However, bugs #1 (zlib.c) and #3 (div64.h) disappear if I compile
> > my kernels with gcc-3.2.2 instead of 2.95.4, which is a strong
> > indication that 2.95.4 is broken on PPC. Is this something that's
> > well-known to PPC people?
> > 
> > The patches are included below for reference.
> 
> It would be interesting to see the section dumps of the resulting
> coff image and compare the version that works and the one that
> doesn't. I still suspect some alignement crap, seeing this may
> eventually show it.

That's certainly possible. I was rebuilding 2.4.21-pre7 with both
compilers, and suddenly the gcc-2.95.4-built vmlinux.coff succeeded
to boot. I didn't expect that, since I've been fighting these boot
problems for weeks now.

I managed to reproduce the problem with 2.4.20 vanilla + only the
one patch to ld.script to fix the CLAIM error on "loading .data":
the kernel compiled with gcc-3.2.2 boots, the one compiled with
gcc-2.95.4 fails at the "clearing .bss" step. The images, vmlinux
and vmlinux.coff for both compiler versions, and .config are in
<http://www.csd.uu.se/~mikpe/linux/powerpc/> in case anyone wants
to check what's wrong with the 2.95.4 build.

/Mikael

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc-2.95 broken on PPC?
  2003-04-10 17:52 Dan Kegel
  2003-04-10 17:50 ` Daniel Jacobowitz
  2003-04-10 21:20 ` Wolfgang Denk
@ 2003-04-10 21:32 ` Jörn Engel
  2 siblings, 0 replies; 10+ messages in thread
From: Jörn Engel @ 2003-04-10 21:32 UTC (permalink / raw)
  To: Dan Kegel; +Cc: wd, Linux Kernel Mailing List

On Thu, 10 April 2003 10:52:15 -0700, Dan Kegel wrote:
> 
> Hi Wolfgang, when you say you see more problems with gcc-3.x
> compilers, what is x?  I'd understand if you saw problems
> with gcc-3.0.*, but I had hoped that gcc-3.2.2 would compile
> good kernels for ppc.
> (Me, I'm still using Montavista Linux 2.0's gcc-2.95.3 to build my ppc 
> kernels,
> but am looking for an excuse to switch to gcc-3.2.* or gcc-3.3.*.)

We've had a "problem" with 3.2. Some conditional new code looked like
this:

#define LONG_MACRO \
	asm \
	asm \
	asm \
#ifdef FOO \
	asm \
	asm \
#else \
	asm \
#endif \
	asm \
	asm

Interesting, isn't it? The fun part was that it was compiling cleanly
in 3.2, but not in 2.95.
Sadly, noone bothered to compile this with 2.95 for a long time.

Jörn

-- 
More computing sins are committed in the name of efficiency (without
necessarily achieving it) than for any other single reason - including
blind stupidity.
-- W. A. Wulf 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc-2.95 broken on PPC?
  2003-04-10 17:52 Dan Kegel
  2003-04-10 17:50 ` Daniel Jacobowitz
@ 2003-04-10 21:20 ` Wolfgang Denk
  2003-04-10 21:32 ` Jörn Engel
  2 siblings, 0 replies; 10+ messages in thread
From: Wolfgang Denk @ 2003-04-10 21:20 UTC (permalink / raw)
  To: Dan Kegel; +Cc: Linux Kernel Mailing List

In message <3E95AF4F.20105@kegel.com> you wrote:
> The Denkster wrote:
>
> > This is speculation only. We use gcc-2.95.4 as part of  our  ELDK  in
> > all  of our projects, and a lot of people are using these tools, too.
> > We definitely see more problems with gcc-3.x compilers.
> 
> Hi Wolfgang, when you say you see more problems with gcc-3.x
> compilers, what is x?  I'd understand if you saw problems

There were serios problems with 3.0. I never tested 3.1.  I  believed
3.2  was OK, but I every now and then problems pop up that seem to be
compiler related. Never found time to investigate, though.

> with gcc-3.0.*, but I had hoped that gcc-3.2.2 would compile
> good kernels for ppc.
> (Me, I'm still using Montavista Linux 2.0's gcc-2.95.3 to build my ppc kernels,
> but am looking for an excuse to switch to gcc-3.2.* or gcc-3.3.*.)

I just heard that gdb 5.2.1 shows some problems when built  with  gcc
3.2  as  sipped with RH-8.0, and the problem goes away when compiling
with 2.95.[34]. The information might be wrong  or  a  misinterpreta-
tion, but I'm still suspicious.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd@denx.de
Why is an average signature file longer than an average Perl script??

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc-2.95 broken on PPC?
@ 2003-04-10 17:52 Dan Kegel
  2003-04-10 17:50 ` Daniel Jacobowitz
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Dan Kegel @ 2003-04-10 17:52 UTC (permalink / raw)
  To: wd, Linux Kernel Mailing List

The Denkster wrote:
>> However, bugs #1 (zlib.c) and #3 (div64.h) disappear if I compile
>> my kernels with gcc-3.2.2 instead of 2.95.4, which is a strong
>> indication that 2.95.4 is broken on PPC. Is this something that's
> 
> This is speculation only. We use gcc-2.95.4 as part of  our  ELDK  in
> all  of our projects, and a lot of people are using these tools, too.
> We definitely see more problems with gcc-3.x compilers.

Hi Wolfgang, when you say you see more problems with gcc-3.x
compilers, what is x?  I'd understand if you saw problems
with gcc-3.0.*, but I had hoped that gcc-3.2.2 would compile
good kernels for ppc.
(Me, I'm still using Montavista Linux 2.0's gcc-2.95.3 to build my ppc kernels,
but am looking for an excuse to switch to gcc-3.2.* or gcc-3.3.*.)
- Dan

-- 
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gcc-2.95 broken on PPC?
  2003-04-10 17:52 Dan Kegel
@ 2003-04-10 17:50 ` Daniel Jacobowitz
  2003-04-10 21:20 ` Wolfgang Denk
  2003-04-10 21:32 ` Jörn Engel
  2 siblings, 0 replies; 10+ messages in thread
From: Daniel Jacobowitz @ 2003-04-10 17:50 UTC (permalink / raw)
  To: Dan Kegel; +Cc: wd, Linux Kernel Mailing List

On Thu, Apr 10, 2003 at 10:52:15AM -0700, Dan Kegel wrote:
> The Denkster wrote:
> >>However, bugs #1 (zlib.c) and #3 (div64.h) disappear if I compile
> >>my kernels with gcc-3.2.2 instead of 2.95.4, which is a strong
> >>indication that 2.95.4 is broken on PPC. Is this something that's
> >
> >This is speculation only. We use gcc-2.95.4 as part of  our  ELDK  in
> >all  of our projects, and a lot of people are using these tools, too.
> >We definitely see more problems with gcc-3.x compilers.
> 
> Hi Wolfgang, when you say you see more problems with gcc-3.x
> compilers, what is x?  I'd understand if you saw problems
> with gcc-3.0.*, but I had hoped that gcc-3.2.2 would compile
> good kernels for ppc.
> (Me, I'm still using Montavista Linux 2.0's gcc-2.95.3 to build my ppc 
> kernels,
> but am looking for an excuse to switch to gcc-3.2.* or gcc-3.3.*.)
> - Dan

Both 3.2 and 3.3 are working well for us here.  3.2's received much
better testing.  I think we tripped up about four bugs in 3.2.2 that
needed patches, but that's well below par compared to 2.95.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-04-12 19:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-10 12:56 gcc-2.95 broken on PPC? mikpe
2003-04-10 14:20 ` Benjamin Herrenschmidt
2003-04-10 14:42 ` Wolfgang Denk
2003-04-10 17:52 Dan Kegel
2003-04-10 17:50 ` Daniel Jacobowitz
2003-04-10 21:20 ` Wolfgang Denk
2003-04-10 21:32 ` Jörn Engel
2003-04-11 15:01 mikpe
2003-04-12 15:36 Dan Kegel
2003-04-12 19:12 ` Peter Barada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).