Re: Linux 2.0.3x & gcc 2.8

Bernd Schmidt (crux@Pool.Informatik.RWTH-Aachen.DE)
Fri, 6 Feb 1998 12:00:23 +0100 (MET)


On Thu, 5 Feb 1998, Linus Torvalds wrote:
> On Thu, 5 Feb 1998, Gabriel Paubert wrote:
> >
> > FYI, I digged my personal mail archives and found that I had been able to
> > produce bad code under similar circumstances with gcc-2.7.2.1, I have
> > unfortunately deleted the source example and it was 3 months ago :-(.
>
> Note that that is _definitely_ a bug in 2.7.2.1, and nobody has ever even
> tried to explain it away, I think.
>
> The silly thing is that there was already a one-liner fix for gcc posted
> that fixed gcc to generate code according to the documentation. So the gcc
> people do know about this all, but as far as I can tell nobody has decided
> what the eventual behaviour should be..

I'd certainly like to see the one-liner fix if someone has it. I can provide
a program that fails with gcc-2.7.2 and 2.8.0 (and probably every gcc version
that was ever released):

---- begin program
int main ()
{
int foo;
__asm__ ("xorl %%eax,%%eax" : "=r" (foo) : "0" (1) : "eax");
if (foo == 0)
abort ();
__asm__ ("xorl %%ebx,%%ebx" : "=r" (foo) : "0" (1) : "ebx");
if (foo == 0)
abort ();
__asm__ ("xorl %%ecx,%%ecx" : "=r" (foo) : "0" (1) : "ecx");
if (foo == 0)
abort ();
__asm__ ("xorl %%edx,%%edx" : "=r" (foo) : "0" (1) : "edx");
if (foo == 0)
abort ();
__asm__ ("xorl %%edi,%%edi" : "=r" (foo) : "0" (1) : "edi");
if (foo == 0)
abort ();
__asm__ ("xorl %%esi,%%esi" : "=r" (foo) : "0" (1) : "esi");
if (foo == 0)
abort ();
__asm__ ("xorl %%ebp,%%ebp" : "=r" (foo) : "0" (1) : "ebp");
if (foo == 0)
abort ();
return 0;
}
---- end program

One of the assembler statements will use the clobbered register for the output
constraint. (You obviously need to compile with -fomit-frame-pointer or the
program does not even make sense.)
The lesson to be learned from this: asm statements do not work as advertised
in the GCC documentation, at least not on the i386. The compiler _will_
ignore the specified clobbers if it can't find a register. And I have strong
doubts that this can be fixed with a one-line patch.

So, it would be sensible to have workarounds for this in the kernel. GCC 2.8
has an immense number of bug fixes over 2.7.2, and telling people to use the
old compiler is Wrong, IMHO. Just run the c-torture test or the egcs
testsuite on 2.7.2 and see what you get.

Bernd
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu