[PATCH] Fix gcc 4.0 vs CONFIG_ALTIVEC

Benjamin Herrenschmidt benh at kernel.crashing.org
Tue May 3 15:34:58 EST 2005


Hi !

gcc-4.0 generates altivec code implicitely when -mcpu insidates an
altivec capable CPU which is not suitable for the kenrel. However, we
used to set -mcpu=970 when CONFIG_ALTIVEC was set because a gcc-3.x bug
prevented from using -maltivec along with -mcpu=power4, thus prevented
building the RAID6 altivec code.

This patch fixes all of this by testing for the gcc version. If 4.0 or
later, just normally use -mcpu=power4 and let the RAID6 code add
-maltivec to the few files it needs to be compiled with altivec support.
For 3.x, we still use -mcpu=970 to work around the above problem, which
is fine as 3.x will never implicitely generate altivec code.

The Makefile hackery may not be the most lovely, I welcome anybody more
skilled than me to improve it.

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>

Index: linux-work/arch/ppc64/Makefile
===================================================================
--- linux-work.orig/arch/ppc64/Makefile	2005-05-02 10:48:08.000000000 +1000
+++ linux-work/arch/ppc64/Makefile	2005-05-03 14:38:43.000000000 +1000
@@ -56,13 +56,20 @@
 CFLAGS		+= -msoft-float -pipe -mminimal-toc -mtraceback=none \
 		   -mcall-aixdesc
 
+GCC_VERSION     := $(call cc-version)
+GCC_BROKEN_VEC	:= $(shell if [ $(GCC_VERSION) -lt 0400 ] ; then echo "y"; fi ;)
+
 ifeq ($(CONFIG_POWER4_ONLY),y)
 ifeq ($(CONFIG_ALTIVEC),y)
+ifeq ($(GCC_BROKEN_VEC),y)
 	CFLAGS += $(call cc-option,-mcpu=970)
 else
 	CFLAGS += $(call cc-option,-mcpu=power4)
 endif
 else
+	CFLAGS += $(call cc-option,-mcpu=power4)
+endif
+else
 	CFLAGS += $(call cc-option,-mtune=power4)
 endif
 






More information about the Linuxppc64-dev mailing list