FASTCALL in egcs was Re: Kernel 2.1.117 OOPS bug report

Andi Kleen (ak@muc.de)
21 Aug 1998 23:04:29 +0200


In article <Pine.LNX.3.96.980821055644.3089B-100000@penguin.transmeta.com>,
Linus Torvalds <torvalds@transmeta.com> writes:
> On Thu, 20 Aug 1998, rbarnett wrote:
>>
>> I'm using egcs-2.90.27 980315 (egcs-1.0.2 release) with binutils
>> 2.8.1.0.23.
>>
>> Running gdb 4.17 on vmlinux (2.1.117) displays the following output:
>>
>> (gdb) x/10i __switch_to
>> 0xc01088d0 <__switch_to>: pushl %esi
>> 0xc01088d1 <__switch_to+1>: pushl %ebx
>> 0xc01088d2 <__switch_to+2>: movl 0xc(%esp,1),%ebx
>> 0xc01088d6 <__switch_to+6>: movl 0x10(%esp,1),%ecx

> Ok, egcs for some reason refuses to do the fastcall thing.

>> Your interpretation? Shall I reinstall GNU gcc and abandon egcs?

> I wonder. The above certainly implies that at least your particular
> version of egcs cannot compile the current kernels, but I don't know why.
> Before abandoning egcs you might want to talk to some egcs people to see
> whether there is some simple way to make egcs do the right thing.

The position of Jeffrew Law on this is:

<quote>
> A new problem that just has appeared today is that Linux 2.1 uses
> __attribute__((regparm)) for some critical functions, and at least egcs 1.0
> seems to have problems to generate correct code with this in all cases.
Oh god. Please stop them from doing this. regparm does not work on
the x86 and will never work correctly on the x86. They're just going
to shoot themselves in the foot.
</quote>

So would you consider the appended patch?

One problem with this (and the workaround in asm-i386/spinlock.h) is
that it adds additional dependencies for loadable kernel modules. But I
don't see a better easy way. Maybe it should be documented somewhere at
least @)

Index: linux/include/linux/kernel.h
===================================================================
RCS file: /vger/u4/cvs/linux/include/linux/kernel.h,v
retrieving revision 1.14
diff -u -r1.14 kernel.h
--- kernel.h 1998/06/12 04:55:25 1.14
+++ kernel.h 1998/08/21 20:41:21
@@ -33,7 +33,7 @@
# define ATTRIB_NORET __attribute__((noreturn))
# define NORET_AND noreturn,

-#ifdef __i386__
+#if defined(__i386__) && !((__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
#define FASTCALL(x) x __attribute__((regparm(3)))
#else
#define FASTCALL(x) x

-Andi

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html