arch/powerpc: Fix zImage wrapper with 64bit only toolchains

Submitted by Cyril Bur on March 16, 2017, 7:49 a.m.

Details

Message ID 20170316074948.5955-1-cyrilbur@gmail.com
State New
Headers show

Commit Message

Cyril Bur March 16, 2017, 7:49 a.m.
Historically the zImage wrapper has needed to be compiled 32bit to run
on 32bit only platforms. Today some platforms can have 64bit wrappers as
they've always been 64bit compatible, notably little endian systems.

Problems arise when a kernel and zImage are cross compiled with a 64bit
only toolchain. The Makefile will determine that the toolchain is not
32bit compatible and whilst attempting to fall back to CROSS32CC or
CROSS32_COMPILE which are unlikely to be set, it falls back to using
`gcc`, the host compiler.

On platforms that can have the wrapper compiled 64bit (and where the
compiler is not 32bit capable), the Makefile should first fall back to
the compiler it used for the rest of the kernel.

Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
---
 arch/powerpc/Makefile | 10 ++++++++++
 1 file changed, 10 insertions(+)

Patch hide | download patch | download mbox

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 8b433334d5af..e7a90952ed36 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -25,6 +25,16 @@  ifeq ($(CROSS32_COMPILE),)
 CROSS32CC	:= $(CC) -m32
 KBUILD_ARFLAGS	+= --target=elf32-powerpc
 endif
+else
+ifeq ($(CONFIG_PPC64_BOOT_WRAPPER),y)
+ifeq ($(CROSS32_COMPILE),)
+#The 64bit only toolchain is perfectly capable of building a 64bit
+#boot wrapper.
+#So use it
+CROSS32CC	:= $(CC)
+CROSS32AR	:= $(AR)
+endif
+endif
 endif
 
 export CROSS32CC CROSS32AR