Skip to contentSkip to conversation

Don't override CONFIG_64BIT for ARCH={i386,x86_64} builds

PATCH Applied David Woodhouse 3 participants 7 messages Feb 11, 2009 – Jun 30, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't override CONFIG_64BIT for ARCH={i386,x86_64} builds

It is a steaming great pain in the arse when the value of CONFIG_64BIT explicitly written in my .config file is overridden by the value of $ARCH inferred from the environment.

If I have a 32-bit .config and I happen to build it without remembering to put 'ARCH=i386' on the make command line, it shouldn't force CONFIG_64BIT=y and reconfigure.

This patch should fix that, while still allowing defconfig to work as it currently does for both 32-bit and 64-bit environments, and still giving the default value of CONFIG_64BIT according to $ARCH. It's just that it won't _force_ a change to CONFIG_64BIT when it's set to something other than what $ARCH would imply.

arch/x86/Kconfig +1 -1
index 73f7fe8..516046d 100644
@@ -3,7 +3,7 @@ mainmenu "Linux Kernel Configuration for x86"
 
 # Select 32 or 64 bit
 config 64BIT
-	bool "64-bit kernel" if ARCH = "x86"
+	bool "64-bit kernel"
 	default ARCH = "x86_64"
 	help
 	  Say yes to build a 64-bit kernel - formerly known as x86_64
Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
Applied
#1 lore raw
Quoted 8 lines · David Woodhouse

It is a steaming great pain in the arse when the value of CONFIG_64BIT explicitly written in my .config file is overridden by the value of $ARCH inferred from the environment.

If I have a 32-bit .config and I happen to build it without remembering to put 'ARCH=i386' on the make command line, it shouldn't force CONFIG_64BIT=y and reconfigure.

Quoted 7 lines

This patch should fix that, while still allowing defconfig to work as it currently does for both 32-bit and 64-bit environments, and still giving the default value of CONFIG_64BIT according to $ARCH. It's just that it won't _force_ a change to CONFIG_64BIT when it's set to something other than what $ARCH would imply.

Applied to tip:x86/ugent, thanks David!

Ingo

#2 lore raw
Quoted 17 lines · Ingo Molnar
Quoted 14 lines · David Woodhouse

It is a steaming great pain in the arse when the value of CONFIG_64BIT explicitly written in my .config file is overridden by the value of $ARCH inferred from the environment.

If I have a 32-bit .config and I happen to build it without remembering to put 'ARCH=i386' on the make command line, it shouldn't force CONFIG_64BIT=y and reconfigure.

This patch should fix that, while still allowing defconfig to work as it currently does for both 32-bit and 64-bit environments, and still giving the default value of CONFIG_64BIT according to $ARCH. It's just that it won't _force_ a change to CONFIG_64BIT when it's set to something other than what $ARCH would imply.

Quoted 3 lines
Quoted 1 line

Applied to tip:x86/ugent, thanks David!

i removed it again, because it regresses randconfig behavior:

titan:~/tip> grep X86_32 .config; make ARCH=x86_64 randconfig; grep X86_32 .config # CONFIG_X86_32 is not set
scripts/kconfig/conf -r arch/x86/Kconfig
#

 # configuration written to .config
 #
 CONFIG_X86_32=y
 CONFIG_X86_32_SMP=y
 CONFIG_X86_32_LAZY_GS=y
 CONFIG_X86_32_ALWAYS_ON=y

I dont mind the change you are after, but randconfig should work as expected too: if ARCH=x86_64 is passed it should generate a 64-bit randconfig, not a 50% 32-bit one.

Ingo

#3 lore raw
Quoted 19 lines · Ingo Molnar
Quoted 17 lines · Ingo Molnar
Quoted 14 lines · David Woodhouse

It is a steaming great pain in the arse when the value of CONFIG_64BIT explicitly written in my .config file is overridden by the value of $ARCH inferred from the environment.

If I have a 32-bit .config and I happen to build it without remembering to put 'ARCH=i386' on the make command line, it shouldn't force CONFIG_64BIT=y and reconfigure.

This patch should fix that, while still allowing defconfig to work as it currently does for both 32-bit and 64-bit environments, and still giving the default value of CONFIG_64BIT according to $ARCH. It's just that it won't _force_ a change to CONFIG_64BIT when it's set to something other than what $ARCH would imply.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Applied to tip:x86/ugent, thanks David!

i removed it again, because it regresses randconfig behavior:

Ew, that's a nasty thing to be prioritising over day-to-day usability, and the fact that I can't just do 'make bzImage' without it screwing up and asking me to reconfigure.

Isn't there a CONFIG_RANDCONFIG option? We could make it
bool "64-bit kernel" if !CONFIG_RANDCONFIG

Alternatively, we could just the top-level Makefile set ARCH=x86 when it's inferred from the environment, and let people override it to i386 or x86_64 if they want to.

Signature · 1 line
dwmw2
#4 lore raw
Quoted 5 lines · David Woodhouse

Ew, that's a nasty thing to be prioritising over day-to-day usability, and the fact that I can't just do 'make bzImage' without it screwing up and asking me to reconfigure.

Quoted 7 lines

Isn't there a CONFIG_RANDCONFIG option? We could make it
bool "64-bit kernel" if !CONFIG_RANDCONFIG

Alternatively, we could just the top-level Makefile set ARCH=x86 when it's inferred from the environment, and let people override it to i386 or x86_64 if they want to.

I think the fundamental problem here is that "make randconfig" is allowed to retain *any* information from the previous .config; the same is true for "make all*config", "make defconfig", etc. These by definition should blast the current configuration away.

Now, "make randconfig" should ideally be able to generate either a 32- or a 64-bit configuration (which would have to be done correctly), but if ARCH is set we need to honor it.

-hpa

#5 lore raw
Quoted 5 lines · H. Peter Anvin
Quoted 4 lines · David Woodhouse

Ew, that's a nasty thing to be prioritising over day-to-day usability, and the fact that I can't just do 'make bzImage' without it screwing up and asking me to reconfigure.

That argument is flawed because it could be used against just about any regression that happens in the kernel: if only the new behavior is deemed more important than the regression that it introduces.

As i said, there's no real problem here, i dont mind the change you are proposing, but it needs to be done without introducing clearly nonsensical regressions.

Quoted 8 lines
Quoted 7 lines

Isn't there a CONFIG_RANDCONFIG option? We could make it
bool "64-bit kernel" if !CONFIG_RANDCONFIG

Alternatively, we could just the top-level Makefile set ARCH=x86 when it's inferred from the environment, and let people override it to i386 or x86_64 if they want to.

Quoted 8 lines

I think the fundamental problem here is that "make randconfig" is allowed to retain *any* information from the previous .config; the same is true for "make all*config", "make defconfig", etc. These by definition should blast the current configuration away.

Now, "make randconfig" should ideally be able to generate either a 32- or a 64-bit configuration (which would have to be done correctly), but if ARCH is set we need to honor it.

Yep, as long as an explicit ARCH override is honored i dont mind some side-effects on randconfig. (although people do have scripting around randconfig so we need to make sure it's all sane.)

Ingo

#6 lore raw
In reply to Ingo Molnar
Quoted 15 lines · Ingo Molnar

i removed it again, because it regresses randconfig behavior:

titan:~/tip> grep X86_32 .config; make ARCH=x86_64 randconfig; grep
X86_32 .config
# CONFIG_X86_32 is not set
scripts/kconfig/conf -r arch/x86/Kconfig
#

 # configuration written to .config
 #
 CONFIG_X86_32=y
 CONFIG_X86_32_SMP=y
 CONFIG_X86_32_LAZY_GS=y
 CONFIG_X86_32_ALWAYS_ON=y
Quoted 3 lines

I dont mind the change you are after, but randconfig should work as expected too: if ARCH=x86_64 is passed it should generate a 64-bit randconfig, not a 50% 32-bit one.

I still think that's a crap argument -- randconfig is _supposed_ to give you a random config -- it's not as if you're going to boot it anyway.

If you want to have a _partially_ random config you should do that with something like 'make CONFIG_FOO=y randconfig'. I think we should drop the historical baggage of 'ARCH=i386' and 'ARCH=x86_64' completely.

But I've just spent a few days testing the wrong damn kernel because 'make oldconfig' silently changed architectures on the config I was given to test -- a bug which you seem to think is _less_ important than the 'bug' that randconfig actually gives you what you asked for.

So I'll have another go at fixing it in a way that preserves your silly 'make ARCH=x86_64 almost-random-config', this time by letting $(ARCH) default to x86.

I didn't do it this way before, because I wanted 'make defconfig' to give you a config which matched the architecture you're running on. I've achieved that a different way now though.

For those using 'make config' from scratch, I made it default to x86_64 instead of i386. That's probably a saner choice, these days.

--------------
Subject: Don't silently override CONFIG_64BIT in 'make oldconfig'

It is a steaming great pain in the arse when the value of CONFIG_64BIT explicitly written in my .config file is overridden by the value of $ARCH inferred from the environment.

If I have a 32-bit .config and I happen to build it without remembering to put 'ARCH=i386' on the make command line, it shouldn't force CONFIG_64BIT=y and reconfigure.

This patch should fix that, while still allowing defconfig to work as it currently does for both 32-bit and 64-bit environments.

The default when running 'make config' is no longer automatic -- it's set to 64-bit. It wasn't possible to preserve this behaviour without also breaking things for the strange people who want 'make randconfig' not to actually be completely random.

Makefile +2 -1
index d1216fe..c944d6e 100644
@@ -157,7 +157,8 @@ export srctree objtree VPATH TOPDIR
 # 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/ \
arch/x86/Kconfig +1 -1
index d1430ef..3f5bbfe 100644
@@ -4,7 +4,7 @@ mainmenu "Linux Kernel Configuration for x86"
 # 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
arch/x86/Makefile +4 -0
index 1b68659..3c6c6ea 100644
@@ -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
Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation