[U-Boot] [PATCH] MIPS: refactor setting of compiler options

Daniel Schwierzeck daniel.schwierzeck at gmail.com
Wed Oct 29 19:19:27 CET 2014


Refactor and unify all compiler settings in arch/mips/config.mk.
Also add tune flags for each supported CPU type.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck at gmail.com>

---
This patch depends on the patch series "MIPS Kconfig updates"

 arch/mips/config.mk            | 42 +++++++++++++++++++++++++++++-------------
 arch/mips/cpu/mips32/config.mk | 14 --------------
 arch/mips/cpu/mips64/config.mk | 14 --------------
 3 files changed, 29 insertions(+), 41 deletions(-)

diff --git a/arch/mips/config.mk b/arch/mips/config.mk
index a2d07af..b758116 100644
--- a/arch/mips/config.mk
+++ b/arch/mips/config.mk
@@ -5,25 +5,41 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-ifeq ($(CROSS_COMPILE),)
-CROSS_COMPILE := mips_4KC-
+ifdef CONFIG_SYS_BIG_ENDIAN
+32bit-emul		:= elf32btsmip
+64bit-emul		:= elf64btsmip
+32bit-bfd		:= elf32-tradbigmips
+64bit-bfd		:= elf64-tradbigmips
+PLATFORM_CPPFLAGS	+= -EB
+PLATFORM_LDFLAGS	+= -EB
 endif
 
-# Handle special prefix in ELDK 4.0 toolchain
-ifneq (,$(findstring 4KCle,$(CROSS_COMPILE)))
-ENDIANNESS := -EL
+ifdef CONFIG_SYS_LITTLE_ENDIAN
+32bit-emul		:= elf32ltsmip
+64bit-emul		:= elf64ltsmip
+32bit-bfd		:= elf32-tradlittlemips
+64bit-bfd		:= elf64-tradlittlemips
+PLATFORM_CPPFLAGS	+= -EL
+PLATFORM_LDFLAGS	+= -EL
 endif
 
-ifdef CONFIG_SYS_LITTLE_ENDIAN
-ENDIANNESS := -EL
+ifdef CONFIG_32BIT
+PLATFORM_CPPFLAGS	+= -mabi=32
+PLATFORM_LDFLAGS	+= -m $(32bit-emul)
+OBJCOPYFLAGS		+= -O $(32bit-bfd)
 endif
 
-ifdef CONFIG_SYS_BIG_ENDIAN
-ENDIANNESS := -EB
+ifdef CONFIG_64BIT
+PLATFORM_CPPFLAGS	+= -mabi=64
+PLATFORM_LDFLAGS	+= -m$(64bit-emul)
+OBJCOPYFLAGS		+= -O $(64bit-bfd)
 endif
 
-# Default to EB if no endianess is configured
-ENDIANNESS ?= -EB
+cpuflags-$(CONFIG_CPU_MIPS32_R1) += -march=mips32 -Wa,-mips32
+cpuflags-$(CONFIG_CPU_MIPS32_R2) += -march=mips32r2 -Wa,-mips32r2
+cpuflags-$(CONFIG_CPU_MIPS64_R1) += -march=mips64 -Wa,-mips64
+cpuflags-$(CONFIG_CPU_MIPS64_R2) += -march=mips64r2 -Wa,-mips64r2
+PLATFORM_CPPFLAGS += $(cpuflags-y)
 
 PLATFORM_CPPFLAGS += -D__MIPS__
 
@@ -49,9 +65,9 @@ __HAVE_ARCH_GENERIC_BOARD := y
 # On the other hand, we want PIC in the U-Boot code to relocate it from ROM
 # to RAM. $28 is always used as gp.
 #
-PLATFORM_CPPFLAGS		+= -G 0 -mabicalls -fpic $(ENDIANNESS)
+PLATFORM_CPPFLAGS		+= -G 0 -mabicalls -fpic
 PLATFORM_CPPFLAGS		+= -msoft-float
-PLATFORM_LDFLAGS		+= -G 0 -static -n -nostdlib $(ENDIANNESS)
+PLATFORM_LDFLAGS		+= -G 0 -static -n -nostdlib
 PLATFORM_RELFLAGS		+= -ffunction-sections -fdata-sections
 LDFLAGS_FINAL			+= --gc-sections -pie
 OBJCOPYFLAGS			+= -j .text -j .rodata -j .data -j .got
diff --git a/arch/mips/cpu/mips32/config.mk b/arch/mips/cpu/mips32/config.mk
index 332cd62..4257c56 100644
--- a/arch/mips/cpu/mips32/config.mk
+++ b/arch/mips/cpu/mips32/config.mk
@@ -5,19 +5,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-#
-# Default optimization level for MIPS32
-#
-# Note: Toolchains with binutils prior to v2.16
-# are no longer supported by U-Boot MIPS tree!
-#
-PLATFORM_CPPFLAGS += -DCONFIG_MIPS32 -march=mips32r2
-PLATFORM_CPPFLAGS += -mabi=32 -DCONFIG_32BIT
-ifdef CONFIG_SYS_BIG_ENDIAN
-PLATFORM_LDFLAGS  += -m elf32btsmip
-else
-PLATFORM_LDFLAGS  += -m elf32ltsmip
-endif
-
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x80200000 \
 			       -T $(srctree)/examples/standalone/mips.lds
diff --git a/arch/mips/cpu/mips64/config.mk b/arch/mips/cpu/mips64/config.mk
index c55eb7f..96eb829 100644
--- a/arch/mips/cpu/mips64/config.mk
+++ b/arch/mips/cpu/mips64/config.mk
@@ -5,19 +5,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-#
-# Default optimization level for MIPS64
-#
-# Note: Toolchains with binutils prior to v2.16
-# are no longer supported by U-Boot MIPS tree!
-#
-PLATFORM_CPPFLAGS += -DCONFIG_MIPS64 -march=mips64
-PLATFORM_CPPFLAGS += -mabi=64 -DCONFIG_64BIT
-ifdef CONFIG_SYS_BIG_ENDIAN
-PLATFORM_LDFLAGS  += -m elf64btsmip
-else
-PLATFORM_LDFLAGS  += -m elf64ltsmip
-endif
-
 CONFIG_STANDALONE_LOAD_ADDR ?= 0xffffffff80200000 \
 			       -T $(srctree)/examples/standalone/mips64.lds
-- 
2.1.1



More information about the U-Boot mailing list