2003-06-23 13:34:16

by Mikael Pettersson

[permalink] [raw]
Subject: [PATCH][2.5.73] restore UP spinlock workaround for gcc-2.95.3

[Sent to Linus and Andi, forgot to cc: lkml]

This patch reverts Andi's change to include/linux/spinlock.h
which made gcc-2.95 use empty structs and empty initializers for
spinlocks on UP. gcc-2.95.3 requires the workaround. Please apply.

A short boot-rebuild-kernel-reboot cycle with 2.5.73 compiled
with gcc-2.95.3 resulted in five "Unitialized timer!" stack
traces on my P4, the first three during boot+init. Recompiling
with gcc-3.2.2, or with 2.95.3 and Andi's patch reverted,
eliminated these problems.

At least on x86 gcc-2.95.3 compiles faster and generates smaller
object code than 3.x.y for at lot of us, so I'd prefer to restore
the workaround rather than deprecating 2.95.3.

/Mikael

--- linux-2.5.73/include/linux/spinlock.h.~1~ 2003-06-23 13:07:39.000000000 +0200
+++ linux-2.5.73/include/linux/spinlock.h 2003-06-23 13:46:09.000000000 +0200
@@ -146,8 +146,13 @@
/*
* gcc versions before ~2.95 have a nasty bug with empty initializers.
*/
-typedef struct { } spinlock_t;
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { }
+#if (__GNUC__ > 2)
+ typedef struct { } spinlock_t;
+ #define SPIN_LOCK_UNLOCKED (spinlock_t) { }
+#else
+ typedef struct { int gcc_is_buggy; } spinlock_t;
+ #define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 }
+#endif

/*
* If CONFIG_SMP is unset, declare the _raw_* definitions as nops


2003-06-24 04:05:57

by Miles Bader

[permalink] [raw]
Subject: Re: [PATCH][2.5.73] restore UP spinlock workaround for gcc-2.95.3

Also on the v850, a usable gcc-3.x is a relatively recent thing, so I
still use gcc-2.x for most things -- and without the spinlock
workaround, gcc-2.x for the v850 crashes. Perhaps other archs also have
similar issues (not everything is as well-supported as i386!).

Given that the spinlock workaround is an extremely small and isolated
piece of code, there doesn't really seem to be benefit to removing it,
so Linus, please apply Mikael's patch to restore the workaround.

Thanks,

-Miles
--
`Life is a boundless sea of bitterness'