Skip to contentSkip to conversation

cant compile on alpha with gcc-4.3 and CONFIG_ALPHA_NAUTILUS

PATCH Daniel Drake 2 participants 3 messages Jan 10, 2009 – Jan 12, 2009 Alpha port

lore
Share & tools
lore
#0 lore raw

Hi,

As reported here:
http://bugs.gentoo.org/show_bug.cgi?id=254150

.config here:
http://bugs.gentoo.org/attachment.cgi?id=177958&action=view

Compile fails for the CONFIG_ALPHA_NAUTILUS systype on gcc 4.3, due to gcc's new array bounds checking:
CC arch/alpha/kernel/irq_srm.o
cc1: warnings being treated as errors arch/alpha/kernel/irq_srm.c: In function 'init_srm_irqs':
arch/alpha/kernel/irq_srm.c:69: error: array subscript is above array bounds
arch/alpha/kernel/irq_srm.c:70: error: array subscript is above array bounds
make[1]: *** [arch/alpha/kernel/irq_srm.o] Error 1

I was surprised to see that alpha has -Werror set, but I see that is also true of some other architectures. Ordinarily, bounds checking is only a warning.

gcc is both right and wrong with this warning. It is right, because nautilus hits this in arch/alpha/include/asm/irq.h:
#else /* everyone else */

# define NR_IRQS	16
#endif

And init_srm_irqs() would clearly go above the size of the array:

	for (i = 16; i < max; ++i)

But gcc is also wrong, in that it is assuming that init_srm_irqs() would be called with max > 16. In fact, in this configuration, init_srm_irqs() is never called at all (but I am not sure how we could expect gcc to know this, given that object files are compiled individually). It is only called on two of the many alpha systypes, as far as I can see.

To fix this, we could remove -Werror or we could restructure the irq_srm
code so that it is only compiled on systems that use it. One small
function (srm_device_interrupt) is used all over the place so would have
to be separated. Patch attached, which has been compile-tested on nautilus. The disadvantage is that srm_device_interrupt() is now built on all alpha sys types, but it is so small that it doesn't seem worth creating its own file or creating ifdef spaghetti.

Thoughts?

Daniel

From: Daniel Drake <[email protected]>
https://bugs.gentoo.org/show_bug.cgi?id=254150
Disclaimer: I know nothing about alpha!

arch/alpha/kernel/Makefile +8 -8
Index: linux-2.6.28-gentoo/arch/alpha/kernel/Makefile
===================================================================
@@ -57,7 +57,7 @@ obj-$(CONFIG_ALPHA_TITAN)	+= core_titan.
 obj-$(CONFIG_ALPHA_WILDFIRE)	+= core_wildfire.o
 
 # Board support
-obj-$(CONFIG_ALPHA_ALCOR)	+= sys_alcor.o irq_i8259.o irq_srm.o
+obj-$(CONFIG_ALPHA_ALCOR)	+= sys_alcor.o irq_i8259.o
 obj-$(CONFIG_ALPHA_CABRIOLET)	+= sys_cabriolet.o irq_i8259.o irq_srm.o \
 				   ns87312.o
 obj-$(CONFIG_ALPHA_EB164)	+= sys_cabriolet.o irq_i8259.o irq_srm.o \
@@ -78,19 +78,19 @@ obj-$(CONFIG_ALPHA_JENSEN)	+= sys_jensen
 obj-$(CONFIG_ALPHA_MARVEL)	+= sys_marvel.o 
 obj-$(CONFIG_ALPHA_MIATA)	+= sys_miata.o irq_pyxis.o irq_i8259.o \
 				   es1888.o smc37c669.o
-obj-$(CONFIG_ALPHA_MIKASA)	+= sys_mikasa.o irq_i8259.o irq_srm.o
-obj-$(CONFIG_ALPHA_NAUTILUS)	+= sys_nautilus.o irq_i8259.o irq_srm.o
+obj-$(CONFIG_ALPHA_MIKASA)	+= sys_mikasa.o irq_i8259.o
+obj-$(CONFIG_ALPHA_NAUTILUS)	+= sys_nautilus.o irq_i8259.o
 obj-$(CONFIG_ALPHA_NORITAKE)	+= sys_noritake.o irq_i8259.o
 obj-$(CONFIG_ALPHA_RAWHIDE)	+= sys_rawhide.o irq_i8259.o
 obj-$(CONFIG_ALPHA_RUFFIAN)	+= sys_ruffian.o irq_pyxis.o irq_i8259.o
 obj-$(CONFIG_ALPHA_RX164)	+= sys_rx164.o irq_i8259.o
 obj-$(CONFIG_ALPHA_SABLE)	+= sys_sable.o
 obj-$(CONFIG_ALPHA_LYNX)	+= sys_sable.o
-obj-$(CONFIG_ALPHA_BOOK1)	+= sys_sio.o irq_i8259.o irq_srm.o ns87312.o
-obj-$(CONFIG_ALPHA_AVANTI)	+= sys_sio.o irq_i8259.o irq_srm.o ns87312.o
-obj-$(CONFIG_ALPHA_NONAME)	+= sys_sio.o irq_i8259.o irq_srm.o ns87312.o
-obj-$(CONFIG_ALPHA_P2K)		+= sys_sio.o irq_i8259.o irq_srm.o ns87312.o
-obj-$(CONFIG_ALPHA_XL)		+= sys_sio.o irq_i8259.o irq_srm.o ns87312.o
+obj-$(CONFIG_ALPHA_BOOK1)	+= sys_sio.o irq_i8259.o ns87312.o
+obj-$(CONFIG_ALPHA_AVANTI)	+= sys_sio.o irq_i8259.o ns87312.o
+obj-$(CONFIG_ALPHA_NONAME)	+= sys_sio.o irq_i8259.o ns87312.o
+obj-$(CONFIG_ALPHA_P2K)		+= sys_sio.o irq_i8259.o ns87312.o
+obj-$(CONFIG_ALPHA_XL)		+= sys_sio.o irq_i8259.o ns87312.o
 obj-$(CONFIG_ALPHA_SX164)	+= sys_sx164.o irq_pyxis.o irq_i8259.o \
 				   irq_srm.o smc37c669.o
 obj-$(CONFIG_ALPHA_TAKARA)	+= sys_takara.o irq_i8259.o ns87312.o
arch/alpha/kernel/irq.c +8 -0
Index: linux-2.6.28-gentoo/arch/alpha/kernel/irq.c
===================================================================
@@ -159,3 +159,11 @@ handle_irq(int irq)
 	__do_IRQ(irq);
 	irq_exit();
 }
+
+void
+srm_device_interrupt(unsigned long vector)
+{
+	int irq = (vector - 0x800) >> 4;
+	handle_irq(irq);
+}
+
arch/alpha/kernel/irq_srm.c +0 -6
Index: linux-2.6.28-gentoo/arch/alpha/kernel/irq_srm.c
===================================================================
@@ -71,9 +71,3 @@ init_srm_irqs(long max, unsigned long ig
 	}
 }
 
-void 
-srm_device_interrupt(unsigned long vector)
-{
-	int irq = (vector - 0x800) >> 4;
-	handle_irq(irq);
-}
#1 lore raw
Quoted 9 lines · Daniel Drake

To fix this, we could remove -Werror or we could restructure the irq_srm code so that it is only compiled on systems that use it. One small function (srm_device_interrupt) is used all over the place so would have to be separated. Patch attached, which has been compile-tested on nautilus. The disadvantage is that srm_device_interrupt() is now built on all alpha sys types, but it is so small that it doesn't seem worth creating its own file or creating ifdef spaghetti.

Thoughts?

Your patch looks fine, but there is simpler fix which makes the compiler to optimize problematic code away on systems with NR_IRQS <= 16.

Ivan.

arch/alpha/kernel/irq_srm.c +2 -0
index 3221201..a03fbca 100644
@@ -63,6 +63,8 @@ init_srm_irqs(long max, unsigned long ignore_mask)
 {
 	long i;
 
+	if (NR_IRQS <= 16)
+		return;
 	for (i = 16; i < max; ++i) {
 		if (i < 64 && ((ignore_mask >> i) & 1))
 			continue;
#2 lore raw
Quoted 2 lines · Ivan Kokshaysky

Your patch looks fine, but there is simpler fix which makes the compiler to optimize problematic code away on systems with NR_IRQS <= 16.

Yes, I guess that works too. Would you like me to submit that to Andrew or are you going to take care of it?

cheers
Daniel