aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2016-08-09 08:43:46 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2016-08-10 09:01:53 -0400
commit164af597ce945751e2dcd53d0a86e84203a6d117 (patch)
treebd8d5b3d11681d5a8859ef20efe4bb31be785eb6
parent97f6e0cc35026a2a09147a6da636d901525e1969 (diff)
powerpc/Makefile: Use cflags-y/aflags-y for setting endian options
When we introduced the little endian support, we added the endian flags to CC directly using override. I don't know the history of why we did that, I suspect no one does. Although this mostly works, it has one bug, which is that CROSS32CC doesn't get -mbig-endian. That means when the compiler is little endian by default and the user is building big endian, vdso32 is incorrectly compiled as little endian and the kernel fails to build. Instead we can add the endian flags to cflags-y/aflags-y, and then append those to KBUILD_CFLAGS/KBUILD_AFLAGS. This has the advantage of being 1) less ugly, 2) the documented way of adding flags in the arch Makefile and 3) it fixes building vdso32 with a LE toolchain. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/Makefile22
1 files changed, 12 insertions, 10 deletions
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index ca254546cd05..1934707bf321 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -66,29 +66,28 @@ endif
66UTS_MACHINE := $(OLDARCH) 66UTS_MACHINE := $(OLDARCH)
67 67
68ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) 68ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
69override CC += -mlittle-endian
70ifneq ($(cc-name),clang)
71override CC += -mno-strict-align
72endif
73override AS += -mlittle-endian
74override LD += -EL 69override LD += -EL
75override CROSS32CC += -mlittle-endian
76override CROSS32AS += -mlittle-endian 70override CROSS32AS += -mlittle-endian
77LDEMULATION := lppc 71LDEMULATION := lppc
78GNUTARGET := powerpcle 72GNUTARGET := powerpcle
79MULTIPLEWORD := -mno-multiple 73MULTIPLEWORD := -mno-multiple
80KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect) 74KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
81else 75else
82ifeq ($(call cc-option-yn,-mbig-endian),y)
83override CC += -mbig-endian
84override AS += -mbig-endian
85endif
86override LD += -EB 76override LD += -EB
87LDEMULATION := ppc 77LDEMULATION := ppc
88GNUTARGET := powerpc 78GNUTARGET := powerpc
89MULTIPLEWORD := -mmultiple 79MULTIPLEWORD := -mmultiple
90endif 80endif
91 81
82cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
83cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
84ifneq ($(cc-name),clang)
85 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align
86endif
87
88aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
89aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
90
92ifeq ($(HAS_BIARCH),y) 91ifeq ($(HAS_BIARCH),y)
93override AS += -a$(CONFIG_WORD_SIZE) 92override AS += -a$(CONFIG_WORD_SIZE)
94override LD += -m elf$(CONFIG_WORD_SIZE)$(LDEMULATION) 93override LD += -m elf$(CONFIG_WORD_SIZE)$(LDEMULATION)
@@ -232,6 +231,9 @@ cpu-as-$(CONFIG_E200) += -Wa,-me200
232KBUILD_AFLAGS += $(cpu-as-y) 231KBUILD_AFLAGS += $(cpu-as-y)
233KBUILD_CFLAGS += $(cpu-as-y) 232KBUILD_CFLAGS += $(cpu-as-y)
234 233
234KBUILD_AFLAGS += $(aflags-y)
235KBUILD_CFLAGS += $(cflags-y)
236
235head-y := arch/powerpc/kernel/head_$(CONFIG_WORD_SIZE).o 237head-y := arch/powerpc/kernel/head_$(CONFIG_WORD_SIZE).o
236head-$(CONFIG_8xx) := arch/powerpc/kernel/head_8xx.o 238head-$(CONFIG_8xx) := arch/powerpc/kernel/head_8xx.o
237head-$(CONFIG_40x) := arch/powerpc/kernel/head_40x.o 239head-$(CONFIG_40x) := arch/powerpc/kernel/head_40x.o