powerpc: Fix defconfig choice logic when cross compiling [Linux 5.2]

powerpc: Fix defconfig choice logic when cross compiling [Linux 5.2]

This Linux kernel change "powerpc: Fix defconfig choice logic when cross compiling" is included in the Linux 5.2 release. This change is authored by Michael Ellerman <mpe [at] ellerman.id.au> on Thu Feb 7 16:16:52 2019 +1100. The commit for this change in Linux stable tree is af5cd05 (patch).

powerpc: Fix defconfig choice logic when cross compiling

Our logic for choosing defconfig doesn't work well in some situations.

For example if you're on a ppc64le machine but you specify a non-empty
CROSS_COMPILE, in order to use a non-default toolchain, then defconfig
will give you ppc64_defconfig (big endian):

  $ make CROSS_COMPILE=~/toolchains/gcc-8/bin/powerpc-linux- defconfig
  *** Default configuration is based on 'ppc64_defconfig'

This is because we assume that CROSS_COMPILE being set means we
can't be on a ppc machine and rather than checking we just default to

We should just ignore CROSS_COMPILE, instead check the machine with
uname and if it's one of ppc, ppc64 or ppc64le then use that
defconfig. If it's none of those then we fall back to ppc64_defconfig.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

There are 9 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 arch/powerpc/Makefile | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a1b17bc..64b8a5a 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -34,11 +34,10 @@ ifdef CONFIG_PPC_BOOK3S_32
 KBUILD_CFLAGS      += -mcpu=powerpc

-ifeq ($(CROSS_COMPILE),)
-KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
-KBUILD_DEFCONFIG := ppc64_defconfig
+# If we're on a ppc/ppc64/ppc64le machine use that defconfig, otherwise just use
+# ppc64_defconfig because we have nothing better to go on.
+uname := $(shell uname -m)
+KBUILD_DEFCONFIG := $(if $(filter ppc%,$(uname)),$(uname),ppc64)_defconfig

 ifdef CONFIG_PPC64
 new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)

Leave a Reply

Your email address will not be published. Required fields are marked *