kconfig: store default ARCH in .config
Subsystems (2)
PATCH 1/1 kconfig: store default ARCH in .config
This patch makes cross-compilation configuration fully statefull. Default ARCH is stored in .config as CONFIG_DEFAULT_ARCH. After initial configuration specifying ARCH= is no longer required.
To avoid recursion it is read directly from .config using scritps/config because include/config/auto.conf is not yet included at this point.
--- Documentation/kbuild/makefiles.txt | 2 ++ Makefile | 19 ++++++++++++++----- init/Kconfig | 4 ++++ 3 files changed, 20 insertions(+), 5 deletions(-)
Documentation/kbuild/makefiles.txt +2 -0
@@ -1394,6 +1394,8 @@ The top Makefile exports the following variables: make ARCH=m68k ... + Default $(ARCH) is stored in .config as CONFIG_DEFAULT_ARCH, + so overriding is required only for initial configuration. INSTALL_PATH
Makefile +14 -5
@@ -171,6 +171,8 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) export srctree objtree VPATH +KCONFIG_CONFIG ?= .config +export KCONFIG_CONFIG # SUBARCH tells the usermode build what the underlying arch is. That is set # first, and if a usermode build is happening, the "ARCH=um" on the command
@@ -193,7 +195,18 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ # ARCH can be set during invocation of make: # make ARCH=ia64 # Another way is to have ARCH set in the environment. -# The default ARCH is the host where make is executed. +# If CONFIG_DEFAULT_ARCH is in .config its value is used as default ARCH, +# otherwise the host where make is executed. + +ifndef ARCH + ARCH := $(shell test -e $(KBUILD_OUTPUT)$(KCONFIG_CONFIG) && \ + $(srctree)/scripts/config \ + --file $(KBUILD_OUTPUT)$(KCONFIG_CONFIG) \ + --state "DEFAULT_ARCH") +ifeq ($(filter-out undef,$(ARCH)),) + ARCH := $(SUBARCH) +endif +endif # CROSS_COMPILE specify the prefix used for all executables used # during compilation. Only gcc and related bin-utils executables
@@ -205,7 +218,6 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ # "make" in the configured kernel build directory always uses that. # Default value for CROSS_COMPILE is not to prefix executables # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile -ARCH ?= $(SUBARCH) CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) # Architecture as present in compile.h
@@ -244,9 +256,6 @@ endif # Where to locate arch specific headers hdr-arch := $(SRCARCH) -KCONFIG_CONFIG ?= .config -export KCONFIG_CONFIG - # SHELL used by kbuild CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \
init/Kconfig +4 -0
@@ -2,6 +2,10 @@ config ARCH string option env="ARCH" +config DEFAULT_ARCH + string + default ARCH + config KERNELVERSION string option env="KERNELVERSION"
Quoted 9 lines · Konstantin Khlebnikov
This patch makes cross-compilation configuration fully statefull. Default ARCH is stored in .config as
CONFIG_DEFAULT_ARCH. After initial configuration specifying ARCH= is no longer required.To avoid recursion it is read directly from .config using scritps/config because
include/config/auto.confis not yet included at this point.Signed-off-by Konstantin Khlebnikov <[email protected]>---
It this needed because the Kconfig symbol ARCH is set only if ARCH is set in the environment?
Could the same result be had by saving CONFIG_ARCH in .config (I suppose it actually already is) and then use its value on builds with that .config unless ARCH is specified in the environment again? Ie, change the "option env=[...]" semantics a bit, perhaps by special casing CONFIG_ARCH.
Quoted 74 lines
Documentation/kbuild/makefiles.txt | 2 ++ Makefile | 19 ++++++++++++++----- init/Kconfig | 4 ++++ 3 files changed, 20 insertions(+), 5 deletions(-)Documentation/kbuild/makefiles.txt +2
-0@@ -1394,6 +1394,8 @@ The top Makefile exports the following variables: make ARCH=m68k ... + Default $(ARCH) is stored in .config as CONFIG_DEFAULT_ARCH, + so overriding is required only for initial configuration. INSTALL_PATHMakefile +14
-5@@ -171,6 +171,8 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) export srctree objtree VPATH +KCONFIG_CONFIG ?= .config +export KCONFIG_CONFIG # SUBARCH tells the usermode build what the underlying arch is. That is set # first, and if a usermode build is happening, the "ARCH=um" on the command@@ -193,7 +195,18 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ # ARCH can be set during invocation of make: # make ARCH=ia64 # Another way is to have ARCH set in the environment. -# The default ARCH is the host where make is executed. +# If CONFIG_DEFAULT_ARCH is in .config its value is used as default ARCH, +# otherwise the host where make is executed. + +ifndef ARCH + ARCH := $(shell test -e $(KBUILD_OUTPUT)$(KCONFIG_CONFIG) && \ + $(srctree)/scripts/config \ + --file $(KBUILD_OUTPUT)$(KCONFIG_CONFIG) \ + --state "DEFAULT_ARCH") +ifeq ($(filter-out undef,$(ARCH)),) + ARCH := $(SUBARCH) +endif +endif # CROSS_COMPILE specify the prefix used for all executables used # during compilation. Only gcc and related bin-utils executables@@ -205,7 +218,6 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ # "make" in the configured kernel build directory always uses that. # Default value for CROSS_COMPILE is not to prefix executables # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile -ARCH ?= $(SUBARCH) CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) # Architecture as present in compile.h@@ -244,9 +256,6 @@ endif # Where to locate arch specific headers hdr-arch := $(SRCARCH) -KCONFIG_CONFIG ?= .config -export KCONFIG_CONFIG - # SHELL used by kbuild CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \init/Kconfig +0
-0
init/Kconfig config ARCH · line 11
Quoted 10 lines
init/Kconfig +4
-0@@ -2,6 +2,10 @@ config ARCH string option env="ARCH" +config DEFAULT_ARCH + string + default ARCH + config KERNELVERSION string option env="KERNELVERSION"
Paul Bolle
Quoted 8 lines · Paul Bolle
Quoted 7 lines · Konstantin Khlebnikov
This patch makes cross-compilation configuration fully statefull. Default ARCH is stored in .config as
CONFIG_DEFAULT_ARCH. After initial configuration specifying ARCH= is no longer required.To avoid recursion it is read directly from .config using scritps/config because
include/config/auto.confis not yet included at this point.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Konstantin Khlebnikov <[email protected]>---
It this needed because the
Kconfigsymbol ARCH is set only if ARCH is set in the environment?Could the same result be had by saving
CONFIG_ARCHin .config (I suppose it actually already is) and then use its value on builds with
No, currently it's not saved in .config, so I guess that's why this convoluted approach is needed.
Quoted 3 lines
that .config unless ARCH is specified in the environment again? Ie, change the "option env=[...]" semantics a bit, perhaps by special casing
CONFIG_ARCH.
Indeed.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 12 lines · Geert Uytterhoeven
Quoted 11 lines · Paul Bolle
Quoted 9 lines · Konstantin Khlebnikov
This patch makes cross-compilation configuration fully statefull. Default ARCH is stored in .config as
CONFIG_DEFAULT_ARCH. After initial configuration specifying ARCH= is no longer required.To avoid recursion it is read directly from .config using scritps/config because
include/config/auto.confis not yet included at this point.Signed-off-by Konstantin Khlebnikov <[email protected]>---
Quoted 8 lines
Quoted 5 lines
It this needed because the
Kconfigsymbol ARCH is set only if ARCH is set in the environment?Could the same result be had by saving
CONFIG_ARCHin .config (I suppose it actually already is) and then use its value on builds withNo, currently it's not saved in .config, so I guess that's why this convoluted approach is needed.
Yep, kconfig neither reads nor writres symbols with option env=...
Quoted 6 lines
Quoted 4 lines
that .config unless ARCH is specified in the environment again? Ie, change the "option env=[...]" semantics a bit, perhaps by special casing
CONFIG_ARCH.Indeed.
If it's saved in config value might be out of sync with actual environment:
ARCH != CONFIG_ARCH. So, behaviour becomes too complicated.
Quoted 11 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.orgIn personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 11 lines · Konstantin Khlebnikov
Quoted 6 lines · Geert Uytterhoeven
Quoted 2 lines · Paul Bolle
Could the same result be had by saving
CONFIG_ARCHin .config (I suppose it actually already is) and then use its value on builds withNo, currently it's not saved in .config, so I guess that's why this convoluted approach is needed.
Yep, kconfig neither reads nor writres symbols with option env=...
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
that .config unless ARCH is specified in the environment again? Ie, change the "option env=[...]" semantics a bit, perhaps by special casing
CONFIG_ARCH.Indeed.
If it's saved in config value might be out of sync with actual environment:
ARCH !=CONFIG_ARCH. So, behaviour becomes too complicated.
So let the environment overrules what is saved in the .config. What makes that complicated?
Paul Bolle