[PATCH] Fix corruption of CONFIG_X86_32 in 'make oldconfig'

From: David Woodhouse
Date: Sun May 29 2011 - 18:15:42 EST


I wasted a bunch of time today because I'd taken a .config from my test
machine and tried to build it, and the existing setting of CONFIG_X86_32
got corrupted.

This patch fixes that. Last time I tried to fix this bug, I had to
contend with Ingo's objection that he didn't actually want 'make
randconfig' to give him a random config... so this is a variant of the
patch which lets him use 'make ARCH=i386 randconfig' and 'make
ARCH=x86_64 randconfig' to get not-entirely-random configurations.

I still maintain that if you actually want a non-random 'randconfig',
perhaps because you want it to be bootable on certain test machines,
then you're going to need to hard-code a whole lot more than *one*
config option â and you'd be better off coming up with a proper
mechanism to do *that* instead of preserving the old 'ARCH=i386' and
'ARCH=x86_64' as a dirty hack to achieve it only for the CONFIG_X86_32
option.

Signed-off-by: David Woodhouse <David.Woodhouse@xxxxxxxxx>
---
Same patch as in https://patchwork.kernel.org/patch/33093/

diff --git a/Makefile b/Makefile
index 123d858..7b3b7c5 100644
--- a/Makefile
+++ b/Makefile
@@ -165,7 +165,8 @@ export srctree objtree VPATH
# then ARCH is assigned, getting whatever value it gets normally, and
# SUBARCH is subsequently ignored.

-SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
+SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
+ -e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ \
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index cc6c53a..1f206b0 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1,7 +1,7 @@
# Select 32 or 64 bit
config 64BIT
bool "64-bit kernel" if ARCH = "x86"
- default ARCH = "x86_64"
+ default ARCH != "i386"
---help---
Say yes to build a 64-bit kernel - formerly known as x86_64
Say no to build a 32-bit kernel - formerly known as i386
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index b02e509..94c2d8c 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -2,7 +2,11 @@

# select defconfig based on actual architecture
ifeq ($(ARCH),x86)
+ ifeq ($(shell uname -m),x86_64)
+ KBUILD_DEFCONFIG := x86_64_defconfig
+ else
KBUILD_DEFCONFIG := i386_defconfig
+ endif
else
KBUILD_DEFCONFIG := $(ARCH)_defconfig
endif

--
David Woodhouse Open Source Technology Centre
David.Woodhouse@xxxxxxxxx Intel Corporation

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/