Skip to content

Commit 4dc831a

Browse files
npigginmpe
authored andcommitted
powerpc: Fix compiling a BE kernel with a powerpc64le toolchain
GCC can compile with either endian, but the default ABI version is set based on the default endianness of the toolchain. Alan Modra says: you need both -mbig and -mabi=elfv1 to make a powerpc64le gcc generate powerpc64 code The opposite is true for powerpc64 when generating -mlittle it requires -mabi=elfv2 to generate v2 ABI, which we were already doing. This change adds ABI annotations together with endianness for all cases, LE and BE. This fixes the case of building a BE kernel with a toolchain that is LE by default. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent a6d8a21 commit 4dc831a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

arch/powerpc/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,15 @@ GNUTARGET := powerpc
7272
MULTIPLEWORD := -mmultiple
7373
endif
7474

75-
cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
75+
ifdef CONFIG_PPC64
76+
cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1)
77+
cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mcall-aixdesc)
78+
aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1)
79+
aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
80+
endif
81+
7682
cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
83+
cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
7784
ifneq ($(cc-name),clang)
7885
cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align
7986
endif
@@ -113,7 +120,9 @@ ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
113120
CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
114121
AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2)
115122
else
123+
CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
116124
CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc)
125+
AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
117126
endif
118127
CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
119128
CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)

0 commit comments

Comments
 (0)