[PATCH] Enable compilation on MIPS with gcc-3.3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

arch/mips/Makefile uses gcc's -mcpu= flag to pass subarchitecture
selection choices to gcc. -mcpu= was deprecated in gcc 3.1, and has
been removed as of gcc 3.3. We need to use -march= for gcc 3.x (where
x >= 3), but some versions of gcc don't understand -march= (namely
2.95.x, which some people still use.)

This patch introduces a variable in arch/mips/makefile, gcc-tune-flag,
which is "cpu" if gcc understands -mcpu and "arch" if it doesn't, and
uses it to build the -mcpu=/-march= bits in CFLAGS for each processor
type.

Matt


diff -puN arch/mips/Makefile~mips-arch arch/mips/Makefile
--- linux-2.6.2-rc1-mm2_mips/arch/mips/Makefile~mips-arch	2004-01-25 00:13:03.295170984 -0600
+++ linux-2.6.2-rc1-mm2_mips-arashi/arch/mips/Makefile	2004-01-25 00:23:39.594438792 -0600
@@ -38,6 +38,8 @@ ifdef CONFIG_CROSSCOMPILE
 CROSS_COMPILE		:= $(tool-prefix)
 endif
 
+gcc-tune-flag		= $(shell if $(CC) -dumpspecs | grep mcpu; then echo cpu; else echo arch; fi)
+
 #
 # GCC uses -G 0 -mabicalls -fpic as default.  We don't want PIC in the kernel
 # code since it only slows down the whole thing.  At some point we might make
@@ -75,49 +77,49 @@ check_warning = $(shell if $(CC) $(1) -c
 #                A kernel built those options will only work on hardware which
 #                actually supports this ISA.
 #
-cflags-$(CONFIG_CPU_R3000)	+= -mcpu=r3000
+cflags-$(CONFIG_CPU_R3000)	+= -$(gcc-tune-flag)=r3000
 32bit-isa-$(CONFIG_CPU_R3000)	+= -mips1
 64bit-isa-$(CONFIG_CPU_R3000)	+= -mboom
-cflags-$(CONFIG_CPU_TX39XX)	+= -mcpu=r3000
+cflags-$(CONFIG_CPU_TX39XX)	+= -$(gcc-tune-flag)=r3000
 32bit-isa-$(CONFIG_CPU_TX39XX)	+= -mips1
 64bit-isa-$(CONFIG_CPU_TX39XX)	+= -mboom
-cflags-$(CONFIG_CPU_R6000)	+= -mcpu=r6000
+cflags-$(CONFIG_CPU_R6000)	+= -$(gcc-tune-flag)=r6000
 32bit-isa-$(CONFIG_CPU_R6000)	+= -mips2 -Wa,--trap
 64bit-isa-$(CONFIG_CPU_R6000)	+= -mboom -Wa,--trap
-cflags-$(CONFIG_CPU_R4300)	+= -mcpu=r4300
+cflags-$(CONFIG_CPU_R4300)	+= -$(gcc-tune-flag)=r4300
 32bit-isa-$(CONFIG_CPU_R4300)	+= -mips2 -Wa,--trap
 64bit-isa-$(CONFIG_CPU_R4300)	+= -mips3 -Wa,--trap
-cflags-$(CONFIG_CPU_VR41XX)	+= -mcpu=r4600
+cflags-$(CONFIG_CPU_VR41XX)	+= -$(gcc-tune-flag)=r4600
 32bit-isa-$(CONFIG_CPU_VR41XX)	+= -mips2 -Wa,--trap
 64bit-isa-$(CONFIG_CPU_VR41XX)	+= -mips3 -Wa,--trap
-cflags-$(CONFIG_CPU_R4X00)	+= -mcpu=r4600
+cflags-$(CONFIG_CPU_R4X00)	+= -$(gcc-tune-flag)=r4600
 32bit-isa-$(CONFIG_CPU_R4X00)	+= -mips2 -Wa,--trap
 64bit-isa-$(CONFIG_CPU_R4X00)	+= -mips3 -Wa,--trap
-cflags-$(CONFIG_CPU_MIPS32)	+= $(call check_gcc, -mtune=mips32, -mcpu=r4600)
+cflags-$(CONFIG_CPU_MIPS32)	+= $(call check_gcc, -mtune=mips32, -$(gcc-tune-flag)=r4600)
 32bit-isa-$(CONFIG_CPU_MIPS32)	+= $(call check_gcc, -mips32 -mabi=32, -mips2) -Wa,--trap
 64bit-isa-$(CONFIG_CPU_MIPS32)	+= -mboom
 cflags-$(CONFIG_CPU_MIPS64)	+= 
 32bit-isa-$(CONFIG_CPU_MIPS64)	+= $(call check_gcc, -mips32, -mips2) -Wa,--trap
 64bit-isa-$(CONFIG_CPU_MIPS64)	+= $(call check_gcc, -mips64, -mips4) -Wa,--trap
-cflags-$(CONFIG_CPU_R5000)	+= -mcpu=r8000
+cflags-$(CONFIG_CPU_R5000)	+= -$(gcc-tune-flag)=r8000
 32bit-isa-$(CONFIG_CPU_R5000)	+= -mips2 -Wa,--trap
 64bit-isa-$(CONFIG_CPU_R5000)	+= -mips4 -Wa,--trap
-cflags-$(CONFIG_CPU_R5432)	+= -mcpu=r5000
+cflags-$(CONFIG_CPU_R5432)	+= -$(gcc-tune-flag)=r5000
 32bit-isa-$(CONFIG_CPU_R5432)	+= -mips1 -Wa,--trap
 64bit-isa-$(CONFIG_CPU_R5432)	+= -mips3 -Wa,--trap
-cflags-$(CONFIG_CPU_NEVADA)	+= -mcpu=r8000 -mmad
+cflags-$(CONFIG_CPU_NEVADA)	+= -$(gcc-tune-flag)=r8000 -mmad
 32bit-isa-$(CONFIG_CPU_NEVADA)	+= -mips2 -Wa,--trap
 64bit-isa-$(CONFIG_CPU_NEVADA)	+= -mips3 -Wa,--trap
-cflags-$(CONFIG_CPU_RM7000)	+= $(call check_gcc, -mcpu=r7000, -mcpu=r5000)
+cflags-$(CONFIG_CPU_RM7000)	+= $(call check_gcc, -$(gcc-tune-flag)=r7000, -$(gcc-tune-flag)=r5000)
 32bit-isa-$(CONFIG_CPU_RM7000)	+= -mips2 -Wa,--trap
 64bit-isa-$(CONFIG_CPU_RM7000)	+= -mips4 -Wa,--trap
-cflags-$(CONFIG_CPU_SB1)	+= $(call check_gcc, -mcpu=sb1, -mcpu=r8000)
+cflags-$(CONFIG_CPU_SB1)	+= $(call check_gcc, -$(gcc-tune-flag)=sb1, -$(gcc-tune-flag)=r8000)
 32bit-isa-$(CONFIG_CPU_SB1)	+= $(call check_gcc, -mips32, -mips2) -Wa,--trap
 64bit-isa-$(CONFIG_CPU_SB1)	+= $(call check_gcc, -mips64, -mips4) -Wa,--trap
-cflags-$(CONFIG_CPU_R8000)	+= -mcpu=r8000
+cflags-$(CONFIG_CPU_R8000)	+= -$(gcc-tune-flag)=r8000
 32bit-isa-$(CONFIG_CPU_R8000)	+= -mips2 -Wa,--trap
 64bit-isa-$(CONFIG_CPU_R8000)	+= -mips4 -Wa,--trap
-cflags-$(CONFIG_CPU_R10000)	+= -mcpu=r8000
+cflags-$(CONFIG_CPU_R10000)	+= -$(gcc-tune-flag)=r8000
 32bit-isa-$(CONFIG_CPU_R10000)	+= -mips2 -Wa,--trap
 64bit-isa-$(CONFIG_CPU_R10000)	+= -mips4 -Wa,--trap
 

_

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux