Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* Re: [PATCH] Fix corruption of CONFIG_X86_32 in 'make oldconfig'
       [not found]     ` <201105302040.55509.arnd@arndb.de>
@ 2011-05-30 20:01       ` Randy Dunlap
  0 siblings, 0 replies; 34+ messages in thread
From: Randy Dunlap @ 2011-05-30 20:01 UTC (permalink / raw)
  To: Arnd Bergmann, linux-kbuild
  Cc: David Woodhouse, John Stultz, Ingo Molnar, x86, linux-kernel

On Mon, 30 May 2011 20:40:55 +0200 Arnd Bergmann wrote:

> On Monday 30 May 2011 19:27:31 Randy Dunlap wrote:
> > On Mon, 30 May 2011 13:05:58 +0200 Arnd Bergmann wrote:
> > 
> > Ingo recently wrote:
> > | When it wont boot straight away (often it does) i use a 
> > | Kconfig-needed set of minimal set of configs that enables the minimal 
> > | hardware environment.
> > 
> > which I believe is the same method that is documented in
> > Documentation/kbuild/kconfig.txt, subject "KCONFIG_ALLCONFIG": (partial text)
> > 
> > This enables you to create "miniature" config (miniconfig) or custom
> > config files containing just the config symbols that you are interested
> > in.  Then the kernel config system generates the full .config file,
> > including symbols of your miniconfig file.
> > 
> > This 'KCONFIG_ALLCONFIG' file is a config file which contains
> > (usually a subset of all) preset config symbols.  These variable
> > settings are still subject to normal dependency checks.
> > 
> 
> Very nice, I didn't know about it. Unfortunately, this seems to
> suffer from the same problem as the generic "randconfig" -- it
> ignores all "choice" statements and just uses the default:
> 
> Try for instance
> 
> KCONFIG_ALLCONFIG=arch/arm/configs/omap2plus_defconfig make \
> 	O=obj-allmod/ allnoconfig ARCH=arm
> 
> This is supposed to set CONFIG_ARCH_OMAP, but it instead chooses
> CONFIG_ARCH_VERSATILE, which means it's still useless for me.

baa humbug.

dear linux-kbuild, can "choice" choices be made random during
"make randconfig", please?

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH] Enable 'make CONFIG_FOO=y oldconfig'
       [not found]                   ` <alpine.LFD.2.02.1105302103220.3164@localhost6.localdomain6>
@ 2011-05-30 22:39                     ` David Woodhouse
  2011-05-31  0:24                       ` Arnaud Lacombe
  0 siblings, 1 reply; 34+ messages in thread
From: David Woodhouse @ 2011-05-30 22:39 UTC (permalink / raw)
  To: Ted Ts'o; +Cc: Ingo Molnar, x86, linux-kernel, linux-kbuild

This allows you to set (and clear) config options on the make command
line, for all config targets. For example:

   make CONFIG_64BIT=n randconfig
   make CONFIG_64BIT=n allmodconfig
   make CONFIG_64BIT=y CONFIG_SATA_MV=y oldconfig 

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 006ad81..2b91e3b 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -456,7 +456,7 @@ static struct option long_opts[] = {
 	{NULL, 0, NULL, 0}
 };
 
-int main(int ac, char **av)
+int main(int ac, char **av, char **ep)
 {
 	int opt;
 	const char *name;
@@ -563,6 +563,11 @@ int main(int ac, char **av)
 		break;
 	}
 
+	for ( ; *ep;  ep++) {
+		if (!strncmp(*ep, CONFIG_, strlen(CONFIG_)))
+			conf_set_symbol_from_env(*ep);
+	}
+
 	if (sync_kconfig) {
 		if (conf_get_changed()) {
 			name = getenv("KCONFIG_NOSILENTUPDATE");
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 61c35bf..e8ff902 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -338,6 +338,47 @@ setsym:
 	return 0;
 }
 
+void conf_set_symbol_from_env(char *str)
+{
+	char *p = strchr(str, '=');
+	struct symbol *sym;
+	int def = S_DEF_USER;
+	int def_flags = SYMBOL_DEF << def;
+
+	if (!p)
+		return;
+
+	*p = 0;
+	sym = sym_find(str + strlen(CONFIG_));
+	*p++ = '=';
+
+	if (!sym)
+		return;
+
+	if (!sym_set_string_value(sym, p))
+		return;
+	conf_message("CONFIG_%s set to %s from environment", sym->name, p);
+	if (sym && sym_is_choice_value(sym)) {
+		struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
+		switch (sym->def[def].tri) {
+		case no:
+			break;
+		case mod:
+			if (cs->def[def].tri == yes) {
+				conf_warning("%s creates inconsistent choice state", sym->name);
+				cs->flags &= ~def_flags;
+			}
+			break;
+		case yes:
+			if (cs->def[def].tri != no)
+				conf_warning("override: %s changes choice state", sym->name);
+			cs->def[def].val = sym;
+			break;
+		}
+		cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
+	}
+}
+
 int conf_read(const char *name)
 {
 	struct symbol *sym, *choice_sym;
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index febf0c9..bf6fade 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -91,6 +91,7 @@ char *conf_get_default_confname(void);
 void sym_set_change_count(int count);
 void sym_add_change_count(int count);
 void conf_set_all_new_symbols(enum conf_def_mode mode);
+void conf_set_symbol_from_env(char *);
 
 /* confdata.c and expr.c */
 static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)


-- 
dwmw2


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH] Enable 'make CONFIG_FOO=y oldconfig'
  2011-05-30 22:39                     ` [PATCH] Enable 'make CONFIG_FOO=y oldconfig' David Woodhouse
@ 2011-05-31  0:24                       ` Arnaud Lacombe
  2011-05-31 15:48                         ` David Woodhouse
  0 siblings, 1 reply; 34+ messages in thread
From: Arnaud Lacombe @ 2011-05-31  0:24 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Ted Ts'o, Ingo Molnar, x86, linux-kernel, linux-kbuild

Hi,

On Mon, May 30, 2011 at 6:39 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> This allows you to set (and clear) config options on the make command
> line, for all config targets. For example:
>
>   make CONFIG_64BIT=n randconfig
>   make CONFIG_64BIT=n allmodconfig
>   make CONFIG_64BIT=y CONFIG_SATA_MV=y oldconfig
>
> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
>
This does not seem to work with:

% make CONFIG_ARCH_OMAP=y ARCH=arm allnoconfig
  HOSTCC  scripts/kconfig/conf.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf --allnoconfig Kconfig
#
# configuration written to .config
#

% grep CONFIG_ARCH_OMAP .config
# CONFIG_ARCH_OMAP is not set

It would seem that the underlying symbol is not visible, triggering
the failure of sym_set_tristate_value().

 - Arnaud

> diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
> index 006ad81..2b91e3b 100644
> --- a/scripts/kconfig/conf.c
> +++ b/scripts/kconfig/conf.c
> @@ -456,7 +456,7 @@ static struct option long_opts[] = {
>        {NULL, 0, NULL, 0}
>  };
>
> -int main(int ac, char **av)
> +int main(int ac, char **av, char **ep)
>  {
>        int opt;
>        const char *name;
> @@ -563,6 +563,11 @@ int main(int ac, char **av)
>                break;
>        }
>
> +       for ( ; *ep;  ep++) {
> +               if (!strncmp(*ep, CONFIG_, strlen(CONFIG_)))
> +                       conf_set_symbol_from_env(*ep);
> +       }
> +
>        if (sync_kconfig) {
>                if (conf_get_changed()) {
>                        name = getenv("KCONFIG_NOSILENTUPDATE");
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index 61c35bf..e8ff902 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -338,6 +338,47 @@ setsym:
>        return 0;
>  }
>
> +void conf_set_symbol_from_env(char *str)
> +{
> +       char *p = strchr(str, '=');
> +       struct symbol *sym;
> +       int def = S_DEF_USER;
> +       int def_flags = SYMBOL_DEF << def;
> +
> +       if (!p)
> +               return;
> +
> +       *p = 0;
> +       sym = sym_find(str + strlen(CONFIG_));
> +       *p++ = '=';
> +
> +       if (!sym)
> +               return;
> +
> +       if (!sym_set_string_value(sym, p))
> +               return;
> +       conf_message("CONFIG_%s set to %s from environment", sym->name, p);
> +       if (sym && sym_is_choice_value(sym)) {
> +               struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
> +               switch (sym->def[def].tri) {
> +               case no:
> +                       break;
> +               case mod:
> +                       if (cs->def[def].tri == yes) {
> +                               conf_warning("%s creates inconsistent choice state", sym->name);
> +                               cs->flags &= ~def_flags;
> +                       }
> +                       break;
> +               case yes:
> +                       if (cs->def[def].tri != no)
> +                               conf_warning("override: %s changes choice state", sym->name);
> +                       cs->def[def].val = sym;
> +                       break;
> +               }
> +               cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
> +       }
> +}
> +
>  int conf_read(const char *name)
>  {
>        struct symbol *sym, *choice_sym;
> diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
> index febf0c9..bf6fade 100644
> --- a/scripts/kconfig/lkc.h
> +++ b/scripts/kconfig/lkc.h
> @@ -91,6 +91,7 @@ char *conf_get_default_confname(void);
>  void sym_set_change_count(int count);
>  void sym_add_change_count(int count);
>  void conf_set_all_new_symbols(enum conf_def_mode mode);
> +void conf_set_symbol_from_env(char *);
>
>  /* confdata.c and expr.c */
>  static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
>
>
> --
> dwmw2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH] Enable 'make CONFIG_FOO=y oldconfig'
  2011-05-31  0:24                       ` Arnaud Lacombe
@ 2011-05-31 15:48                         ` David Woodhouse
  2011-05-31 16:12                           ` Arnaud Lacombe
  0 siblings, 1 reply; 34+ messages in thread
From: David Woodhouse @ 2011-05-31 15:48 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: Ted Ts'o, Ingo Molnar, x86, linux-kernel, linux-kbuild

On Mon, 2011-05-30 at 20:24 -0400, Arnaud Lacombe wrote:
> It would seem that the underlying symbol is not visible, triggering
> the failure of sym_set_tristate_value().

Yes, this only lets you set *visible* symbols. If the symbol you're
interested in is not visible because some of its dependencies are not
set, it doesn't go and automatically enable those.

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH] Enable 'make CONFIG_FOO=y oldconfig'
  2011-05-31 15:48                         ` David Woodhouse
@ 2011-05-31 16:12                           ` Arnaud Lacombe
  2011-06-24 13:49                             ` Michal Marek
  0 siblings, 1 reply; 34+ messages in thread
From: Arnaud Lacombe @ 2011-05-31 16:12 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Ted Ts'o, Ingo Molnar, x86, linux-kernel, linux-kbuild

Hi,

On Tue, May 31, 2011 at 11:48 AM, David Woodhouse <dwmw2@infradead.org> wrote:
> On Mon, 2011-05-30 at 20:24 -0400, Arnaud Lacombe wrote:
>> It would seem that the underlying symbol is not visible, triggering
>> the failure of sym_set_tristate_value().
>
> Yes, this only lets you set *visible* symbols. If the symbol you're
> interested in is not visible because some of its dependencies are not
> set, it doesn't go and automatically enable those.
>
As for this choice, it *is* visible. You are missing a call to
`sym_calc_value()' (actually sym_calc_visibility() but it is not
exported) before the conditional to correct the visibility.

Beside that, if the environment is to influence the configuration
unconditionally, it would rather be better to do that when the Kconfig
are parsed.

 - Arnaud

> --
> David Woodhouse                            Open Source Technology Centre
> David.Woodhouse@intel.com                              Intel Corporation
>
>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH] Enable 'make CONFIG_FOO=y oldconfig'
  2011-05-31 16:12                           ` Arnaud Lacombe
@ 2011-06-24 13:49                             ` Michal Marek
  2011-07-29 23:32                               ` [PATCH v2] " David Woodhouse
  2011-07-30  0:49                               ` [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT David Woodhouse
  0 siblings, 2 replies; 34+ messages in thread
From: Michal Marek @ 2011-06-24 13:49 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: David Woodhouse, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild

On 31.5.2011 18:12, Arnaud Lacombe wrote:
> Hi,
>
> On Tue, May 31, 2011 at 11:48 AM, David Woodhouse<dwmw2@infradead.org>  wrote:
>> On Mon, 2011-05-30 at 20:24 -0400, Arnaud Lacombe wrote:
>>> It would seem that the underlying symbol is not visible, triggering
>>> the failure of sym_set_tristate_value().
>>
>> Yes, this only lets you set *visible* symbols. If the symbol you're
>> interested in is not visible because some of its dependencies are not
>> set, it doesn't go and automatically enable those.
>>
> As for this choice, it *is* visible. You are missing a call to
> `sym_calc_value()' (actually sym_calc_visibility() but it is not
> exported) before the conditional to correct the visibility.

David, will you post a patch with this fix?

$ make CONFIG_ARCH_OMAP=y ARCH=arm allnoconfig
$ grep CONFIG_ARCH_OMAP .config
# CONFIG_ARCH_OMAP is not set
vs.
$ echo CONFIG_ARCH_OMAP=y >all.config
$ make  ARCH=arm allnoconfig
$ grep CONFIG_ARCH_OMAP .config
CONFIG_ARCH_OMAP=y
...


> Beside that, if the environment is to influence the configuration
> unconditionally, it would rather be better to do that when the Kconfig
> are parsed.

I don't quite understand what you mean here. The environment variables 
are evaluated right after the potential all*.config file is read. Do you 
think there is a problem with that?

Michal

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2] Enable 'make CONFIG_FOO=y oldconfig'
  2011-06-24 13:49                             ` Michal Marek
@ 2011-07-29 23:32                               ` David Woodhouse
  2011-07-30  1:15                                 ` Arnaud Lacombe
  2011-07-30  0:49                               ` [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT David Woodhouse
  1 sibling, 1 reply; 34+ messages in thread
From: David Woodhouse @ 2011-07-29 23:32 UTC (permalink / raw)
  To: Michal Marek
  Cc: Arnaud Lacombe, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

This allows you to set (and clear) config options on the make command
line, for all config targets. For example:

   make CONFIG_64BIT=n randconfig
   make CONFIG_64BIT=n allmodconfig
   make CONFIG_64BIT=y CONFIG_SATA_MV=y oldconfig

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
v2: Add call to sym_calc_value() before sym_set_string_value(), to set
    symbol visibility. 'make ARCH=arm CONFIG_ARCH_OMAP=y allnoconfig'
    should work correctly now.

 scripts/kconfig/conf.c     |    7 ++++++-
 scripts/kconfig/confdata.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 scripts/kconfig/lkc.h      |    1 +
 3 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 006ad81..2b91e3b 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -456,7 +456,7 @@ static struct option long_opts[] = {
 	{NULL, 0, NULL, 0}
 };
 
-int main(int ac, char **av)
+int main(int ac, char **av, char **ep)
 {
 	int opt;
 	const char *name;
@@ -563,6 +563,11 @@ int main(int ac, char **av)
 		break;
 	}
 
+	for ( ; *ep;  ep++) {
+		if (!strncmp(*ep, CONFIG_, strlen(CONFIG_)))
+			conf_set_symbol_from_env(*ep);
+	}
+
 	if (sync_kconfig) {
 		if (conf_get_changed()) {
 			name = getenv("KCONFIG_NOSILENTUPDATE");
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 2bafd9a..ada3c4b 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -338,6 +338,48 @@ setsym:
 	return 0;
 }
 
+void conf_set_symbol_from_env(char *str)
+{
+	char *p = strchr(str, '=');
+	struct symbol *sym;
+	int def = S_DEF_USER;
+	int def_flags = SYMBOL_DEF << def;
+
+	if (!p)
+		return;
+
+	*p = 0;
+	sym = sym_find(str + strlen(CONFIG_));
+	*p++ = '=';
+
+	if (!sym)
+		return;
+
+	sym_calc_value(sym);
+	if (!sym_set_string_value(sym, p))
+		return;
+	conf_message("CONFIG_%s set to %s from environment", sym->name, p);
+	if (sym && sym_is_choice_value(sym)) {
+		struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
+		switch (sym->def[def].tri) {
+		case no:
+			break;
+		case mod:
+			if (cs->def[def].tri == yes) {
+				conf_warning("%s creates inconsistent choice state", sym->name);
+				cs->flags &= ~def_flags;
+			}
+			break;
+		case yes:
+			if (cs->def[def].tri != no)
+				conf_warning("override: %s changes choice state", sym->name);
+			cs->def[def].val = sym;
+			break;
+		}
+		cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
+	}
+}
+
 int conf_read(const char *name)
 {
 	struct symbol *sym, *choice_sym;
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index f34a0a9..fc2f3ad 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -89,6 +89,7 @@ char *conf_get_default_confname(void);
 void sym_set_change_count(int count);
 void sym_add_change_count(int count);
 void conf_set_all_new_symbols(enum conf_def_mode mode);
+void conf_set_symbol_from_env(char *);
 
 /* confdata.c and expr.c */
 static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
-- 
1.7.6


-- 
dwmw2


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-06-24 13:49                             ` Michal Marek
  2011-07-29 23:32                               ` [PATCH v2] " David Woodhouse
@ 2011-07-30  0:49                               ` David Woodhouse
  2011-07-30  1:26                                 ` Arnaud Lacombe
                                                   ` (3 more replies)
  1 sibling, 4 replies; 34+ messages in thread
From: David Woodhouse @ 2011-07-30  0:49 UTC (permalink / raw)
  To: Michal Marek
  Cc: Arnaud Lacombe, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

I *frequently* waste a bunch of time when I take a 32-bit .config from a
test machine and try to build it on a faster 64-bit system, and its
existing setting of CONFIG_64BIT=n gets *changed* to match the build host.

This is because the default setting for $ARCH when discovered from
'uname' is one of the legacy pre-x86-merge values (i386 or x86_64),
which effectively force the setting of CONFIG_64BIT to match. We should
default to ARCH=x86 instead, finally completing the merge that we
started so long ago.

This patch preserves the behaviour of the legacy ARCH settings for commands
such as:

   make ARCH=x86_64 randconfig
   make ARCH=i386 randconfig

... although since my commit "Enable 'make CONFIG_FOO=y oldconfig'" those
would be better expressed as:

   make CONFIG_64BIT=y randconfig
   make CONFIG_64BIT=n randconfig

... since that is a more generic way to set *any* config option, and
there's no other technical reason to keep the legacy ARCH values around
any more just to achieve that purpose; they could be removed at any
time.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Link: http://lkml.kernel.org/r/1306707270.2029.377.camel@i7.infradead.org
---
v2: Explicitly turn off CONFIG_64BIT in i386_defconfig. The default for
    CONFIG_64BIT has *changed* (from n to y) for ARCH=x86, so it needs to
    be explicitly turned off or 'make i386_defconfig' will give you 64-bit.
v3: Same patch as before; just updated changelog.

 Makefile                        |    3 ++-
 arch/x86/Kconfig                |    2 +-
 arch/x86/Makefile               |    4 ++++
 arch/x86/configs/i386_defconfig |    1 +
 4 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index d018956..303df9b 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 153aa6f..9467fdd 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
diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig
index 2bf18059f..5f96c1c 100644
--- a/arch/x86/configs/i386_defconfig
+++ b/arch/x86/configs/i386_defconfig
@@ -1,3 +1,4 @@
+# CONFIG_64BIT is not set
 CONFIG_EXPERIMENTAL=y
 # CONFIG_LOCALVERSION_AUTO is not set
 CONFIG_SYSVIPC=y
-- 
1.7.6



-- 
dwmw2


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH v2] Enable 'make CONFIG_FOO=y oldconfig'
  2011-07-29 23:32                               ` [PATCH v2] " David Woodhouse
@ 2011-07-30  1:15                                 ` Arnaud Lacombe
  2011-07-30  9:04                                   ` David Woodhouse
  0 siblings, 1 reply; 34+ messages in thread
From: Arnaud Lacombe @ 2011-07-30  1:15 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

Hi,

On Fri, Jul 29, 2011 at 7:32 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> This allows you to set (and clear) config options on the make command
> line, for all config targets. For example:
>
>   make CONFIG_64BIT=n randconfig
>   make CONFIG_64BIT=n allmodconfig
>   make CONFIG_64BIT=y CONFIG_SATA_MV=y oldconfig
>
Technically, kconfig already provides you all the interfaces to set
symbol to a given value, for `randconfig' via "rand.config", for
`all{yes,mod,no}config', via all.{yes,mod,no}config, for oldconfig via
.config. Why another interface ?

> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
> ---
> v2: Add call to sym_calc_value() before sym_set_string_value(), to set
>    symbol visibility. 'make ARCH=arm CONFIG_ARCH_OMAP=y allnoconfig'
>    should work correctly now.
>
>  scripts/kconfig/conf.c     |    7 ++++++-
>  scripts/kconfig/confdata.c |   42 ++++++++++++++++++++++++++++++++++++++++++
>  scripts/kconfig/lkc.h      |    1 +
>  3 files changed, 49 insertions(+), 1 deletions(-)
>
> diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
> index 006ad81..2b91e3b 100644
> --- a/scripts/kconfig/conf.c
> +++ b/scripts/kconfig/conf.c
> @@ -456,7 +456,7 @@ static struct option long_opts[] = {
>        {NULL, 0, NULL, 0}
>  };
>
> -int main(int ac, char **av)
> +int main(int ac, char **av, char **ep)
>  {
>        int opt;
>        const char *name;
> @@ -563,6 +563,11 @@ int main(int ac, char **av)
>                break;
>        }
>
> +       for ( ; *ep;  ep++) {
> +               if (!strncmp(*ep, CONFIG_, strlen(CONFIG_)))
> +                       conf_set_symbol_from_env(*ep);
> +       }
> +
>        if (sync_kconfig) {
>                if (conf_get_changed()) {
>                        name = getenv("KCONFIG_NOSILENTUPDATE");
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index 2bafd9a..ada3c4b 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -338,6 +338,48 @@ setsym:
>        return 0;
>  }
>
> +void conf_set_symbol_from_env(char *str)
> +{
> +       char *p = strchr(str, '=');
> +       struct symbol *sym;
> +       int def = S_DEF_USER;
> +       int def_flags = SYMBOL_DEF << def;
> +
> +       if (!p)
> +               return;
the environment should already gives you the guarantee that `p' won't
be NULL. If that's not the case, the environment is likely to be
broken.

> +
> +       *p = 0;
> +       sym = sym_find(str + strlen(CONFIG_));
> +       *p++ = '=';
> +
> +       if (!sym)
> +               return;
> +
> +       sym_calc_value(sym);
> +       if (!sym_set_string_value(sym, p))
> +               return;
> +       conf_message("CONFIG_%s set to %s from environment", sym->name, p);
please do not hardcode the prefix.

> +       if (sym && sym_is_choice_value(sym)) {
you do not need to test for the validity of a pointer you
unconditionally dereference right before :)

> +               struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
> +               switch (sym->def[def].tri) {
> +               case no:
> +                       break;
> +               case mod:
> +                       if (cs->def[def].tri == yes) {
> +                               conf_warning("%s creates inconsistent choice state", sym->name);
> +                               cs->flags &= ~def_flags;
> +                       }
> +                       break;
> +               case yes:
> +                       if (cs->def[def].tri != no)
> +                               conf_warning("override: %s changes choice state", sym->name);
> +                       cs->def[def].val = sym;
> +                       break;
> +               }
> +               cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
> +       }
> +}
> +
>  int conf_read(const char *name)
>  {
>        struct symbol *sym, *choice_sym;
> diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
> index f34a0a9..fc2f3ad 100644
> --- a/scripts/kconfig/lkc.h
> +++ b/scripts/kconfig/lkc.h
> @@ -89,6 +89,7 @@ char *conf_get_default_confname(void);
>  void sym_set_change_count(int count);
>  void sym_add_change_count(int count);
>  void conf_set_all_new_symbols(enum conf_def_mode mode);
> +void conf_set_symbol_from_env(char *);
>
>  /* confdata.c and expr.c */
>  static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)
> --
> 1.7.6
>
>
> --
> dwmw2
>
>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30  0:49                               ` [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT David Woodhouse
@ 2011-07-30  1:26                                 ` Arnaud Lacombe
  2011-07-30  8:37                                   ` David Woodhouse
  2011-07-30 15:52                                 ` Arnaud Lacombe
                                                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 34+ messages in thread
From: Arnaud Lacombe @ 2011-07-30  1:26 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

Hi,

On Fri, Jul 29, 2011 at 8:49 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> I *frequently* waste a bunch of time when I take a 32-bit .config from a
> test machine and try to build it on a faster 64-bit system, and its
> existing setting of CONFIG_64BIT=n gets *changed* to match the build host.
>
Should we not try to fix this rather than introduce a new interface ?
From my point of view, we (ie. Kbuild) should be intelligent enough to
take the default from the .config, if one is present in the object
directory, rather than trying to impose it's own view on what the ARCH
should be.

Is there case where we would have a .config, but would not use its content ?

Thanks,
 - Arnaud

> This is because the default setting for $ARCH when discovered from
> 'uname' is one of the legacy pre-x86-merge values (i386 or x86_64),
> which effectively force the setting of CONFIG_64BIT to match. We should
> default to ARCH=x86 instead, finally completing the merge that we
> started so long ago.
>
> This patch preserves the behaviour of the legacy ARCH settings for commands
> such as:
>
>   make ARCH=x86_64 randconfig
>   make ARCH=i386 randconfig
>
> ... although since my commit "Enable 'make CONFIG_FOO=y oldconfig'" those
> would be better expressed as:
>
>   make CONFIG_64BIT=y randconfig
>   make CONFIG_64BIT=n randconfig
>
> ... since that is a more generic way to set *any* config option, and
> there's no other technical reason to keep the legacy ARCH values around
> any more just to achieve that purpose; they could be removed at any
> time.
>
> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
> Link: http://lkml.kernel.org/r/1306707270.2029.377.camel@i7.infradead.org
> ---
> v2: Explicitly turn off CONFIG_64BIT in i386_defconfig. The default for
>    CONFIG_64BIT has *changed* (from n to y) for ARCH=x86, so it needs to
>    be explicitly turned off or 'make i386_defconfig' will give you 64-bit.
> v3: Same patch as before; just updated changelog.
>
>  Makefile                        |    3 ++-
>  arch/x86/Kconfig                |    2 +-
>  arch/x86/Makefile               |    4 ++++
>  arch/x86/configs/i386_defconfig |    1 +
>  4 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index d018956..303df9b 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 153aa6f..9467fdd 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
> diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig
> index 2bf18059f..5f96c1c 100644
> --- a/arch/x86/configs/i386_defconfig
> +++ b/arch/x86/configs/i386_defconfig
> @@ -1,3 +1,4 @@
> +# CONFIG_64BIT is not set
>  CONFIG_EXPERIMENTAL=y
>  # CONFIG_LOCALVERSION_AUTO is not set
>  CONFIG_SYSVIPC=y
> --
> 1.7.6
>
>
>
> --
> dwmw2
>
>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30  1:26                                 ` Arnaud Lacombe
@ 2011-07-30  8:37                                   ` David Woodhouse
  2011-07-30 15:21                                     ` Arnaud Lacombe
  0 siblings, 1 reply; 34+ messages in thread
From: David Woodhouse @ 2011-07-30  8:37 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

On Fri, 2011-07-29 at 21:26 -0400, Arnaud Lacombe wrote:
> 
> Should we not try to fix this rather than introduce a new interface ?

This patch *does* fix it, without needing the new interface that I
presented in a separate patch. The two patches I sent are not strictly
dependent on one another.

> From my point of view, we (ie. Kbuild) should be intelligent enough to
> take the default from the .config, if one is present in the object
> directory, rather than trying to impose it's own view on what the ARCH
> should be.
> 
> Is there case where we would have a .config, but would not use its
> content ?

Heh, I think you've missed some of the history here.

I originally, a year or two ago, posted a patch which took precisely the
approach I think you're advocating. It basically made the ARCH=x86
behaviour apply in all cases. It was reverted because it made 'make
randconfig' actually *random* — *even* for the setting of CONFIG_64BIT,
*even* when ARCH=i386 or ARCH=x86_64.

The fact that KCONFIG_ALLCONFIG allows you to override *all* config
options and not just CONFIG_64BIT, and that using the legacy ARCH=
settings wasn't really necessary, was evidently not sufficient. It
apparently *had* to be possible to switch using the command line.

So I did two things — I fixed this patch so that it doesn't break that
legacy use case of 'make ARCH=i386' or 'make ARCH=x86_64' to force the
value of CONFIG_64BIT on or off, and I also posted a separate patch
which gives a more *sensible* way to force *any* config options on or
off from the 'make' command line, since the world is apparently going to
end if we can't do that.

The two patches can be considered to be entirely independent.

-- 
dwmw2


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2] Enable 'make CONFIG_FOO=y oldconfig'
  2011-07-30  1:15                                 ` Arnaud Lacombe
@ 2011-07-30  9:04                                   ` David Woodhouse
  0 siblings, 0 replies; 34+ messages in thread
From: David Woodhouse @ 2011-07-30  9:04 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

On Fri, 2011-07-29 at 21:15 -0400, Arnaud Lacombe wrote:
> Technically, kconfig already provides you all the interfaces to set
> symbol to a given value, for `randconfig' via "rand.config", for
> `all{yes,mod,no}config', via all.{yes,mod,no}config, for oldconfig via
> .config. Why another interface ?

It's useful for some people to be able to do this as simply as possible
from the command line, and they get very upset if you suggest that they
might use those other methods instead.

In particular, some people currently use the legacy 'ARCH=i386' and
'ARCH=x86_64' settings on the command line in order to switch the value
of CONFIG_64BIT on and off for various *config targets¹. In fact, I
think that's the *only* thing that those legacy ARCH settings still do;
they could (technically, at least) be killed off if we have an
alternative way of doing it. This provides an alternative, more generic
way of doing it for *all* config options; not just CONFIG_64BIT and not
just for x86.

(¹ Note: in fact, *many* people use 'ARCH=i386' and 'ARCH=x86_64', but
not really for this purpose. Most people use it just to work around the
bug I fixed in my other patch — that the value of CONFIG_64BIT is
*always* overridden to match the build host, unless you do *something*
on the command line to work around it. Just ARCH=x86 would suffice,
since that makes CONFIG_64BIT work sanely again.)

> > +void conf_set_symbol_from_env(char *str)
> > +{
> > +       char *p = strchr(str, '=');
> > +       struct symbol *sym;
> > +       int def = S_DEF_USER;
> > +       int def_flags = SYMBOL_DEF << def;
> > +
> > +       if (!p)
> > +               return;
> the environment should already gives you the guarantee that `p' won't
> be NULL. If that's not the case, the environment is likely to be
> broken.

Yes, that's true. Nevertheless, I've seen broken environments — there's
no harm in being robust. We can't be robust in the face of *all* the
ways the environment could screw up, of course, but this check doesn't
really hurt. Especially given that the getenv() isn't even *in* this
function, so this function is even more justified in checking its
inputs.

> > +
> > +       *p = 0;
> > +       sym = sym_find(str + strlen(CONFIG_));
> > +       *p++ = '=';
> > +
> > +       if (!sym)
> > +               return;
> > +
> > +       sym_calc_value(sym);
> > +       if (!sym_set_string_value(sym, p))
> > +               return;
> > +       conf_message("CONFIG_%s set to %s from environment", sym->name, p);
> please do not hardcode the prefix.

OK.

> > +       if (sym && sym_is_choice_value(sym)) {
> you do not need to test for the validity of a pointer you
> unconditionally dereference right before :)

That's a copy-and-paste from identical code in conf_read_simple(), which
I suppose should be factored out into a separate function. if I really
understood what it was doing I'd be able to suggest a sane name...
sym_validate_choice_state() perhaps?

I'll do that.

> > +               struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
> > +               switch (sym->def[def].tri) {
> > +               case no:
> > +                       break;
> > +               case mod:
> > +                       if (cs->def[def].tri == yes) {
> > +                               conf_warning("%s creates inconsistent choice state", sym->name);
> > +                               cs->flags &= ~def_flags;
> > +                       }
> > +                       break;
> > +               case yes:
> > +                       if (cs->def[def].tri != no)
> > +                               conf_warning("override: %s changes choice state", sym->name);
> > +                       cs->def[def].val = sym;
> > +                       break;
> > +               }
> > +               cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
> > +       }
> > +}
> > +
-- 
dwmw2


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30  8:37                                   ` David Woodhouse
@ 2011-07-30 15:21                                     ` Arnaud Lacombe
  0 siblings, 0 replies; 34+ messages in thread
From: Arnaud Lacombe @ 2011-07-30 15:21 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

Hi

On Sat, Jul 30, 2011 at 4:37 AM, David Woodhouse <dwmw2@infradead.org> wrote:
> On Fri, 2011-07-29 at 21:26 -0400, Arnaud Lacombe wrote:
>>
>> Should we not try to fix this rather than introduce a new interface ?
>
> This patch *does* fix it, without needing the new interface that I
> presented in a separate patch. The two patches I sent are not strictly
> dependent on one another.
>
>> From my point of view, we (ie. Kbuild) should be intelligent enough to
>> take the default from the .config, if one is present in the object
>> directory, rather than trying to impose it's own view on what the ARCH
>> should be.
>>
>> Is there case where we would have a .config, but would not use its
>> content ?
>
> Heh, I think you've missed some of the history here.
>
> I originally, a year or two ago, posted a patch which took precisely the
> approach I think you're advocating.
Just to make my point clearer, here is what I'd be advocating:

diff --git a/Makefile b/Makefile
index b927e75..a15b773 100644
--- a/Makefile
+++ b/Makefile
@@ -192,7 +192,11 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/
-e s/sun4u/sparc64/ \
 # Default value for CROSS_COMPILE is not to prefix executables
 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
 export KBUILD_BUILDHOST := $(SUBARCH)
+ifeq ($(shell test -e .config && echo n),n)
 ARCH           ?= $(SUBARCH)
+else
+ARCH           ?= $(shell sed '/^\# Linux\/\(.*\) .* Kernel
Configuration/!d; s//\1/' .config)
+endif
 CROSS_COMPILE  ?= $(CONFIG_CROSS_COMPILE:"%"=%)

this work but smells hackish.

 - Arnaud

> It basically made the ARCH=x86
> behaviour apply in all cases. It was reverted because it made 'make
> randconfig' actually *random* — *even* for the setting of CONFIG_64BIT,
> *even* when ARCH=i386 or ARCH=x86_64.
>
> The fact that KCONFIG_ALLCONFIG allows you to override *all* config
> options and not just CONFIG_64BIT, and that using the legacy ARCH=
> settings wasn't really necessary, was evidently not sufficient. It
> apparently *had* to be possible to switch using the command line.
>
> So I did two things — I fixed this patch so that it doesn't break that
> legacy use case of 'make ARCH=i386' or 'make ARCH=x86_64' to force the
> value of CONFIG_64BIT on or off, and I also posted a separate patch
> which gives a more *sensible* way to force *any* config options on or
> off from the 'make' command line, since the world is apparently going to
> end if we can't do that.
>
> The two patches can be considered to be entirely independent.
>
> --
> dwmw2
>
>

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30  0:49                               ` [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT David Woodhouse
  2011-07-30  1:26                                 ` Arnaud Lacombe
@ 2011-07-30 15:52                                 ` Arnaud Lacombe
  2011-07-30 16:19                                   ` David Woodhouse
  2011-07-31 19:40                                   ` Arnaud Lacombe
  2011-07-31  5:18                                 ` Arnaud Lacombe
  2011-07-31 21:47                                 ` Arnaud Lacombe
  3 siblings, 2 replies; 34+ messages in thread
From: Arnaud Lacombe @ 2011-07-30 15:52 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

Hi,

On Fri, Jul 29, 2011 at 8:49 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> I *frequently* waste a bunch of time when I take a 32-bit .config from a
> test machine and try to build it on a faster 64-bit system, and its
> existing setting of CONFIG_64BIT=n gets *changed* to match the build host.
>
> This is because the default setting for $ARCH when discovered from
> 'uname' is one of the legacy pre-x86-merge values (i386 or x86_64),
> which effectively force the setting of CONFIG_64BIT to match. We should
> default to ARCH=x86 instead, finally completing the merge that we
> started so long ago.
>
> This patch preserves the behaviour of the legacy ARCH settings for commands
> such as:
>
>   make ARCH=x86_64 randconfig
>   make ARCH=i386 randconfig
>
> ... although since my commit "Enable 'make CONFIG_FOO=y oldconfig'" those
> would be better expressed as:
>
>   make CONFIG_64BIT=y randconfig
>   make CONFIG_64BIT=n randconfig
>
> ... since that is a more generic way to set *any* config option, and
> there's no other technical reason to keep the legacy ARCH values around
> any more just to achieve that purpose; they could be removed at any
> time.
>
> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
> Link: http://lkml.kernel.org/r/1306707270.2029.377.camel@i7.infradead.org
> ---
> v2: Explicitly turn off CONFIG_64BIT in i386_defconfig. The default for
>    CONFIG_64BIT has *changed* (from n to y) for ARCH=x86, so it needs to
>    be explicitly turned off or 'make i386_defconfig' will give you 64-bit.
> v3: Same patch as before; just updated changelog.
>
>  Makefile                        |    3 ++-
>  arch/x86/Kconfig                |    2 +-
>  arch/x86/Makefile               |    4 ++++
>  arch/x86/configs/i386_defconfig |    1 +
>  4 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index d018956..303df9b 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/ \
this is breaking ARCH=um.

 - Arnaud

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 15:52                                 ` Arnaud Lacombe
@ 2011-07-30 16:19                                   ` David Woodhouse
  2011-07-30 16:33                                     ` Arnaud Lacombe
  2011-07-31 19:40                                   ` Arnaud Lacombe
  1 sibling, 1 reply; 34+ messages in thread
From: David Woodhouse @ 2011-07-30 16:19 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

On Sat, 30 Jul 2011, Arnaud Lacombe wrote:

> this is breaking ARCH=um.

Breaking in what way? Is it just that ARCH=um is broken for SUBARCH=x86, 
and needed to be updated anyway? And still works is you manually set 
SUBARCH to one of the legacy values?

I'll try to reproduce and take a look later thuis evening.

-- 
dwmw2


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 16:19                                   ` David Woodhouse
@ 2011-07-30 16:33                                     ` Arnaud Lacombe
  2011-07-30 18:59                                       ` H. Peter Anvin
  0 siblings, 1 reply; 34+ messages in thread
From: Arnaud Lacombe @ 2011-07-30 16:33 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

Hi,

On Sat, Jul 30, 2011 at 12:19 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> On Sat, 30 Jul 2011, Arnaud Lacombe wrote:
>
>> this is breaking ARCH=um.
>
> Breaking in what way?
from arch/um/Makefile:
[...]
include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)

with the following Makefile-$(SUBARCH) available:

% ls arch/um/Makefile-*
[...] arch/um/Makefile-i386  arch/um/Makefile-x86_64

> Is it just that ARCH=um is broken for SUBARCH=x86,
> and needed to be updated anyway?
>
well, from my point of view, it do not need to be updated. Your patch
corrupt SUBARCH's purpose, that is:

# SUBARCH tells the usermode build what the underlying arch is.

Changing it will start to be really intrusive...

> And still works is you manually set
> SUBARCH to one of the legacy values?
>
no. the toplev Makefile use a direct immediate assignment, not a
conditional one.

 - Arnaud

> I'll try to reproduce and take a look later thuis evening.
>
> --
> dwmw2
>
>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 16:33                                     ` Arnaud Lacombe
@ 2011-07-30 18:59                                       ` H. Peter Anvin
  2011-07-30 20:58                                         ` David Woodhouse
  0 siblings, 1 reply; 34+ messages in thread
From: H. Peter Anvin @ 2011-07-30 18:59 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: David Woodhouse, Michal Marek, Ted Ts'o, Ingo Molnar, x86,
	linux-kernel, linux-kbuild

On 07/30/2011 09:33 AM, Arnaud Lacombe wrote:
>>
> well, from my point of view, it do not need to be updated. Your patch
> corrupt SUBARCH's purpose, that is:
> 
> # SUBARCH tells the usermode build what the underlying arch is.
> 

For klibc integration, we ran into this problem as well: the set of
architectures for the kernel simply isn't the same set as the
architectures for userspace.  For the kernel, x86 is an architecture,
for userspace the architectures are x86_64 or i386 and they are
fundamentally different in many, many ways.

The main problem with SUBARCH is that it is ill-defined in the general
case if SUBARCH contains a user space or a kernel space architecture.
In that sense I would much prefer it if was called, say, USERARCH and
was always available.  It could even be set by Kconfig (CONFIG_USERARCH?)

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 18:59                                       ` H. Peter Anvin
@ 2011-07-30 20:58                                         ` David Woodhouse
  2011-07-30 22:03                                           ` H. Peter Anvin
  2011-07-30 22:21                                           ` Arnaud Lacombe
  0 siblings, 2 replies; 34+ messages in thread
From: David Woodhouse @ 2011-07-30 20:58 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Arnaud Lacombe, Michal Marek, Ted Ts'o, Ingo Molnar, x86,
	linux-kernel, linux-kbuild

On Sat, 2011-07-30 at 11:59 -0700, H. Peter Anvin wrote:
> For klibc integration, we ran into this problem as well: the set of
> architectures for the kernel simply isn't the same set as the
> architectures for userspace.  For the kernel, x86 is an architecture,
> for userspace the architectures are x86_64 or i386 and they are
> fundamentally different in many, many ways.
> 
> The main problem with SUBARCH is that it is ill-defined in the general
> case if SUBARCH contains a user space or a kernel space architecture.
> In that sense I would much prefer it if was called, say, USERARCH and
> was always available.  It could even be set by Kconfig
> (CONFIG_USERARCH?)

In the context of a kernel build that's meaningless though. One kernel
can support *many* types of userspace.

I've just been playing with ARCH=um. It looks like the current state,
even before my patch, is that 'make ARCH=um SUBARCH=x86' is broken.

I'll work on a patch to fix that, and then it will be fine when the
default for SUBARCH changes to be "x86".

(Another option is to make SUBARCH default to x86 *only* if ARCH!=um,
and still use the legacy SUBARCH values when ARCH=um. But I'm not overly
keen on that approach.)

Fixing um to work with ARCH=x86 *ought* to be as simple as doing
something like this:

--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -12,6 +12,15 @@ OS := $(shell uname -s)
 # features.
 SHELL := /bin/bash
 
+# The i386/x86_64 merge hasn't really happened in um-land yet. Fake it.
+ifeq ($(SUBARCH),x86)
+ifeq ($(CONFIG_64BIT),y)
+SUBARCH := x86_64
+else
+SUBARCH := i386
+endif
+endif
+
 filechk_gen_header = $<
 
 core-y                 += $(ARCH_DIR)/kernel/          \

.. but that gives me weird behaviour where it just keeps running
silentoldconfig over and over again.

This patch *does* work, but I'll see if I can make it simpler...

diff --git a/arch/um/Kconfig.x86 b/arch/um/Kconfig.x86
index d31ecf3..576b732 100644
--- a/arch/um/Kconfig.x86
+++ b/arch/um/Kconfig.x86
@@ -19,8 +19,8 @@ config UML_X86
 	select GENERIC_FIND_FIRST_BIT
 
 config 64BIT
-	bool
-	default SUBARCH = "x86_64"
+	bool "64-bit kernel" if SUBARCH = "x86"
+	default SUBARCH != "i386"
 
 config X86_32
 	def_bool !64BIT
diff --git a/arch/um/Makefile b/arch/um/Makefile
index fab8121..562c6cb 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -12,6 +12,17 @@ OS := $(shell uname -s)
 # features.
 SHELL := /bin/bash
 
+# The i386/x86_64 merge hasn't really happened in um-land yet. Fake it.
+ifeq ($(SUBARCH),x86)
+ifeq ($(CONFIG_64BIT),y)
+UMSUBARCH := x86_64
+else
+UMSUBARCH := i386
+endif
+else
+UMSUBARCH := $(SUBARCH)
+endif
+
 filechk_gen_header = $<
 
 core-y			+= $(ARCH_DIR)/kernel/		\
@@ -24,11 +35,11 @@ include $(srctree)/$(ARCH_DIR)/Makefile-skas
 
 SHARED_HEADERS	:= $(ARCH_DIR)/include/shared
 ARCH_INCLUDE	:= -I$(srctree)/$(SHARED_HEADERS)
-ARCH_INCLUDE	+= -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)/shared
+ARCH_INCLUDE	+= -I$(srctree)/$(ARCH_DIR)/sys-$(UMSUBARCH)/shared
 ifneq ($(KBUILD_SRC),)
 ARCH_INCLUDE	+= -I$(SHARED_HEADERS)
 endif
-KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)
+KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(UMSUBARCH)
 
 # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
 # named - it's a common symbol in libpcap, so we get a binary which crashes.
@@ -38,7 +49,7 @@ KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)
 #
 # These apply to USER_CFLAGS to.
 
-KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
+KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(UMSUBARCH)\" \
 	$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap	\
 	-Din6addr_loopback=kernel_in6addr_loopback \
 	-Din6addr_any=kernel_in6addr_any
@@ -49,7 +60,7 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
 	$(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
 	$(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64
 
-include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
+include $(srctree)/$(ARCH_DIR)/Makefile-$(UMSUBARCH)
 
 #This will adjust *FLAGS accordingly to the platform.
 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
@@ -128,8 +139,8 @@ archclean:
 
 # Generated files
 
-$(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE
-	$(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(SUBARCH) $@
+$(ARCH_DIR)/sys-$(UMSUBARCH)/user-offsets.s: FORCE
+	$(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(UMSUBARCH) $@
 
 define filechk_gen-asm-offsets
         (set -e; \
@@ -144,11 +155,11 @@ define filechk_gen-asm-offsets
          echo ""; )
 endef
 
-$(SHARED_HEADERS)/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s
+$(SHARED_HEADERS)/user_constants.h: $(ARCH_DIR)/sys-$(UMSUBARCH)/user-offsets.s
 	$(call filechk,gen-asm-offsets)
 
 $(SHARED_HEADERS)/kern_constants.h:
 	$(Q)mkdir -p $(dir $@)
 	$(Q)echo '#include "../../../../include/generated/asm-offsets.h"' >$@
 
-export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH
+export SUBARCH UMSUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH
diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386
index 302cbe5..b66063b 100644
--- a/arch/um/Makefile-i386
+++ b/arch/um/Makefile-i386
@@ -5,22 +5,22 @@ TOP_ADDR := $(CONFIG_TOP_ADDR)
 START := 0x8048000
 
 LDFLAGS			+= -m elf_i386
-ELF_ARCH		:= $(SUBARCH)
-ELF_FORMAT 		:= elf32-$(SUBARCH)
+ELF_ARCH		:= $(UMSUBARCH)
+ELF_FORMAT 		:= elf32-$(UMSUBARCH)
 OBJCOPYFLAGS  		:= -O binary -R .note -R .comment -S
 HEADER_ARCH		:= x86
 CHECKFLAGS	+= -D__i386__
 
-ifeq ("$(origin SUBARCH)", "command line")
-ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)")
+#ifeq ("$(origin SUBARCH)", "command line")
+#ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)")
 KBUILD_CFLAGS		+= $(call cc-option,-m32)
 KBUILD_AFLAGS		+= $(call cc-option,-m32)
 LINK-y			+= $(call cc-option,-m32)
 UML_OBJCOPYFLAGS	+= -F $(ELF_FORMAT)
 
 export LDFLAGS HOSTCFLAGS HOSTLDFLAGS UML_OBJCOPYFLAGS
-endif
-endif
+#endif
+#endif
 
 # First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y.
 include $(srctree)/arch/x86/Makefile_32.cpu
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile
index b33f4df..c1a2ca3 100644
--- a/arch/um/os-Linux/Makefile
+++ b/arch/um/os-Linux/Makefile
@@ -5,7 +5,7 @@
 
 obj-y = aio.o execvp.o file.o helper.o irq.o main.o mem.o process.o \
 	registers.o sigio.o signal.o start_up.o time.o tty.o uaccess.o \
-	umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/
+	umid.o tls.o user_syms.o util.o drivers/ sys-$(UMSUBARCH)/ skas/
 
 obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o
 

-- 
dwmw2


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 20:58                                         ` David Woodhouse
@ 2011-07-30 22:03                                           ` H. Peter Anvin
  2011-07-30 22:17                                             ` David Woodhouse
  2011-07-30 22:21                                           ` Arnaud Lacombe
  1 sibling, 1 reply; 34+ messages in thread
From: H. Peter Anvin @ 2011-07-30 22:03 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Arnaud Lacombe, Michal Marek, Ted Ts'o, Ingo Molnar, x86,
	linux-kernel, linux-kbuild

On 07/30/2011 01:58 PM, David Woodhouse wrote:
> 
> In the context of a kernel build that's meaningless though. One kernel
> can support *many* types of userspace.
> 

It isn't meaningless for exactly that reason.  For example,
"make ARCH=x86 USERARCH=i386" and "make ARCH=x86 USERARCH=x86_64" both
make sense.  Similarly, "make ARCH=um USERARCH=i386" is different from
"make ARCH=um USERARCH=x86_64".

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 22:03                                           ` H. Peter Anvin
@ 2011-07-30 22:17                                             ` David Woodhouse
  2011-07-30 22:21                                               ` H. Peter Anvin
  2011-07-30 22:24                                               ` Arnaud Lacombe
  0 siblings, 2 replies; 34+ messages in thread
From: David Woodhouse @ 2011-07-30 22:17 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Arnaud Lacombe, Michal Marek, Ted Ts'o, Ingo Molnar, x86,
	linux-kernel, linux-kbuild

On Sat, 2011-07-30 at 15:03 -0700, H. Peter Anvin wrote:
> It isn't meaningless for exactly that reason.  For example,
> "make ARCH=x86 USERARCH=i386" and "make ARCH=x86 USERARCH=x86_64" both
> make sense.  Similarly, "make ARCH=um USERARCH=i386" is different from
> "make ARCH=um USERARCH=x86_64". 

In that case it's redundant with CONFIG_64BIT, isn't it?

-- 
dwmw2


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 22:17                                             ` David Woodhouse
@ 2011-07-30 22:21                                               ` H. Peter Anvin
  2011-07-30 22:24                                               ` Arnaud Lacombe
  1 sibling, 0 replies; 34+ messages in thread
From: H. Peter Anvin @ 2011-07-30 22:21 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Arnaud Lacombe, Michal Marek, Ted Ts'o, Ingo Molnar, x86,
	linux-kernel, linux-kbuild

On 07/30/2011 03:17 PM, David Woodhouse wrote:
> On Sat, 2011-07-30 at 15:03 -0700, H. Peter Anvin wrote:
>> It isn't meaningless for exactly that reason.  For example,
>> "make ARCH=x86 USERARCH=i386" and "make ARCH=x86 USERARCH=x86_64" both
>> make sense.  Similarly, "make ARCH=um USERARCH=i386" is different from
>> "make ARCH=um USERARCH=x86_64". 
> 
> In that case it's redundant with CONFIG_64BIT, isn't it?

Yes, but some architectures have more than one ABI for a particular bitness.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 20:58                                         ` David Woodhouse
  2011-07-30 22:03                                           ` H. Peter Anvin
@ 2011-07-30 22:21                                           ` Arnaud Lacombe
  2011-07-30 22:57                                             ` David Woodhouse
  1 sibling, 1 reply; 34+ messages in thread
From: Arnaud Lacombe @ 2011-07-30 22:21 UTC (permalink / raw)
  To: David Woodhouse
  Cc: H. Peter Anvin, Michal Marek, Ted Ts'o, Ingo Molnar, x86,
	linux-kernel, linux-kbuild

Hi,

On Sat, Jul 30, 2011 at 4:58 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> On Sat, 2011-07-30 at 11:59 -0700, H. Peter Anvin wrote:
>> For klibc integration, we ran into this problem as well: the set of
>> architectures for the kernel simply isn't the same set as the
>> architectures for userspace.  For the kernel, x86 is an architecture,
>> for userspace the architectures are x86_64 or i386 and they are
>> fundamentally different in many, many ways.
>>
>> The main problem with SUBARCH is that it is ill-defined in the general
>> case if SUBARCH contains a user space or a kernel space architecture.
>> In that sense I would much prefer it if was called, say, USERARCH and
>> was always available.  It could even be set by Kconfig
>> (CONFIG_USERARCH?)
>
> In the context of a kernel build that's meaningless though. One kernel
> can support *many* types of userspace.
>
> I've just been playing with ARCH=um. It looks like the current state,
> even before my patch, is that 'make ARCH=um SUBARCH=x86' is broken.
>
I fail to see how, to my understanding, something that has not been
thought to be used that way can be broken ...

> I'll work on a patch to fix that, and then it will be fine when the
> default for SUBARCH changes to be "x86".
>
I still fail to see why you want it that way... You want both ARCH and
SUBARCH to be 'x86' ?

This starts to be a hell lots of deep changes just to fix i386 build
under a fast x86-64 without having to specify ARCH=i386. That job
alone can be done a lot easier.

 - Arnaud

> (Another option is to make SUBARCH default to x86 *only* if ARCH!=um,
> and still use the legacy SUBARCH values when ARCH=um. But I'm not overly
> keen on that approach.)
>
> Fixing um to work with ARCH=x86 *ought* to be as simple as doing
> something like this:
>
> --- a/arch/um/Makefile
> +++ b/arch/um/Makefile
> @@ -12,6 +12,15 @@ OS := $(shell uname -s)
>  # features.
>  SHELL := /bin/bash
>
> +# The i386/x86_64 merge hasn't really happened in um-land yet. Fake it.
> +ifeq ($(SUBARCH),x86)
> +ifeq ($(CONFIG_64BIT),y)
> +SUBARCH := x86_64
> +else
> +SUBARCH := i386
> +endif
> +endif
> +
>  filechk_gen_header = $<
>
>  core-y                 += $(ARCH_DIR)/kernel/          \
>
> .. but that gives me weird behaviour where it just keeps running
> silentoldconfig over and over again.
>
> This patch *does* work, but I'll see if I can make it simpler...
>
> diff --git a/arch/um/Kconfig.x86 b/arch/um/Kconfig.x86
> index d31ecf3..576b732 100644
> --- a/arch/um/Kconfig.x86
> +++ b/arch/um/Kconfig.x86
> @@ -19,8 +19,8 @@ config UML_X86
>        select GENERIC_FIND_FIRST_BIT
>
>  config 64BIT
> -       bool
> -       default SUBARCH = "x86_64"
> +       bool "64-bit kernel" if SUBARCH = "x86"
> +       default SUBARCH != "i386"
>
>  config X86_32
>        def_bool !64BIT
> diff --git a/arch/um/Makefile b/arch/um/Makefile
> index fab8121..562c6cb 100644
> --- a/arch/um/Makefile
> +++ b/arch/um/Makefile
> @@ -12,6 +12,17 @@ OS := $(shell uname -s)
>  # features.
>  SHELL := /bin/bash
>
> +# The i386/x86_64 merge hasn't really happened in um-land yet. Fake it.
> +ifeq ($(SUBARCH),x86)
> +ifeq ($(CONFIG_64BIT),y)
> +UMSUBARCH := x86_64
> +else
> +UMSUBARCH := i386
> +endif
> +else
> +UMSUBARCH := $(SUBARCH)
> +endif
> +
>  filechk_gen_header = $<
>
>  core-y                 += $(ARCH_DIR)/kernel/          \
> @@ -24,11 +35,11 @@ include $(srctree)/$(ARCH_DIR)/Makefile-skas
>
>  SHARED_HEADERS := $(ARCH_DIR)/include/shared
>  ARCH_INCLUDE   := -I$(srctree)/$(SHARED_HEADERS)
> -ARCH_INCLUDE   += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)/shared
> +ARCH_INCLUDE   += -I$(srctree)/$(ARCH_DIR)/sys-$(UMSUBARCH)/shared
>  ifneq ($(KBUILD_SRC),)
>  ARCH_INCLUDE   += -I$(SHARED_HEADERS)
>  endif
> -KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)
> +KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(UMSUBARCH)
>
>  # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
>  # named - it's a common symbol in libpcap, so we get a binary which crashes.
> @@ -38,7 +49,7 @@ KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)
>  #
>  # These apply to USER_CFLAGS to.
>
> -KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
> +KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(UMSUBARCH)\" \
>        $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap      \
>        -Din6addr_loopback=kernel_in6addr_loopback \
>        -Din6addr_any=kernel_in6addr_any
> @@ -49,7 +60,7 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
>        $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
>        $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64
>
> -include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
> +include $(srctree)/$(ARCH_DIR)/Makefile-$(UMSUBARCH)
>
>  #This will adjust *FLAGS accordingly to the platform.
>  include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
> @@ -128,8 +139,8 @@ archclean:
>
>  # Generated files
>
> -$(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE
> -       $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(SUBARCH) $@
> +$(ARCH_DIR)/sys-$(UMSUBARCH)/user-offsets.s: FORCE
> +       $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(UMSUBARCH) $@
>
>  define filechk_gen-asm-offsets
>         (set -e; \
> @@ -144,11 +155,11 @@ define filechk_gen-asm-offsets
>          echo ""; )
>  endef
>
> -$(SHARED_HEADERS)/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s
> +$(SHARED_HEADERS)/user_constants.h: $(ARCH_DIR)/sys-$(UMSUBARCH)/user-offsets.s
>        $(call filechk,gen-asm-offsets)
>
>  $(SHARED_HEADERS)/kern_constants.h:
>        $(Q)mkdir -p $(dir $@)
>        $(Q)echo '#include "../../../../include/generated/asm-offsets.h"' >$@
>
> -export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH
> +export SUBARCH UMSUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH
> diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386
> index 302cbe5..b66063b 100644
> --- a/arch/um/Makefile-i386
> +++ b/arch/um/Makefile-i386
> @@ -5,22 +5,22 @@ TOP_ADDR := $(CONFIG_TOP_ADDR)
>  START := 0x8048000
>
>  LDFLAGS                        += -m elf_i386
> -ELF_ARCH               := $(SUBARCH)
> -ELF_FORMAT             := elf32-$(SUBARCH)
> +ELF_ARCH               := $(UMSUBARCH)
> +ELF_FORMAT             := elf32-$(UMSUBARCH)
>  OBJCOPYFLAGS           := -O binary -R .note -R .comment -S
>  HEADER_ARCH            := x86
>  CHECKFLAGS     += -D__i386__
>
> -ifeq ("$(origin SUBARCH)", "command line")
> -ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)")
> +#ifeq ("$(origin SUBARCH)", "command line")
> +#ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)")
>  KBUILD_CFLAGS          += $(call cc-option,-m32)
>  KBUILD_AFLAGS          += $(call cc-option,-m32)
>  LINK-y                 += $(call cc-option,-m32)
>  UML_OBJCOPYFLAGS       += -F $(ELF_FORMAT)
>
>  export LDFLAGS HOSTCFLAGS HOSTLDFLAGS UML_OBJCOPYFLAGS
> -endif
> -endif
> +#endif
> +#endif
>
>  # First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y.
>  include $(srctree)/arch/x86/Makefile_32.cpu
> diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile
> index b33f4df..c1a2ca3 100644
> --- a/arch/um/os-Linux/Makefile
> +++ b/arch/um/os-Linux/Makefile
> @@ -5,7 +5,7 @@
>
>  obj-y = aio.o execvp.o file.o helper.o irq.o main.o mem.o process.o \
>        registers.o sigio.o signal.o start_up.o time.o tty.o uaccess.o \
> -       umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/
> +       umid.o tls.o user_syms.o util.o drivers/ sys-$(UMSUBARCH)/ skas/
>
>  obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o
>
>
> --
> dwmw2
>
>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 22:17                                             ` David Woodhouse
  2011-07-30 22:21                                               ` H. Peter Anvin
@ 2011-07-30 22:24                                               ` Arnaud Lacombe
  2011-07-30 22:34                                                 ` David Woodhouse
  1 sibling, 1 reply; 34+ messages in thread
From: Arnaud Lacombe @ 2011-07-30 22:24 UTC (permalink / raw)
  To: David Woodhouse
  Cc: H. Peter Anvin, Michal Marek, Ted Ts'o, Ingo Molnar, x86,
	linux-kernel, linux-kbuild

Hi,

On Sat, Jul 30, 2011 at 6:17 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> On Sat, 2011-07-30 at 15:03 -0700, H. Peter Anvin wrote:
>> It isn't meaningless for exactly that reason.  For example,
>> "make ARCH=x86 USERARCH=i386" and "make ARCH=x86 USERARCH=x86_64" both
>> make sense.  Similarly, "make ARCH=um USERARCH=i386" is different from
>> "make ARCH=um USERARCH=x86_64".
>
> In that case it's redundant with CONFIG_64BIT, isn't it?
>
How do you plan to handle x32, if it ever makes it to mainline ?

 - Arnaud

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 22:24                                               ` Arnaud Lacombe
@ 2011-07-30 22:34                                                 ` David Woodhouse
  2011-07-30 22:39                                                   ` H. Peter Anvin
  0 siblings, 1 reply; 34+ messages in thread
From: David Woodhouse @ 2011-07-30 22:34 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: H. Peter Anvin, Michal Marek, Ted Ts'o, Ingo Molnar, x86,
	linux-kernel, linux-kbuild

On Sat, 2011-07-30 at 18:24 -0400, Arnaud Lacombe wrote:
> How do you plan to handle x32, if it ever makes it to mainline ? 

I was pondering that. Surely it would involve porting the kernel itself
to x32? And there's never going to be any motivation for that *other*
than UML, so I can't really see it happening.

What does 'uname -m' give under x32, anyway?


-- 
dwmw2


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 22:34                                                 ` David Woodhouse
@ 2011-07-30 22:39                                                   ` H. Peter Anvin
  0 siblings, 0 replies; 34+ messages in thread
From: H. Peter Anvin @ 2011-07-30 22:39 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Arnaud Lacombe, Michal Marek, Ted Ts'o, Ingo Molnar, x86,
	linux-kernel, linux-kbuild

On 07/30/2011 03:34 PM, David Woodhouse wrote:
> On Sat, 2011-07-30 at 18:24 -0400, Arnaud Lacombe wrote:
>> How do you plan to handle x32, if it ever makes it to mainline ? 
> 
> I was pondering that. Surely it would involve porting the kernel itself
> to x32? And there's never going to be any motivation for that *other*
> than UML, so I can't really see it happening.
> 
> What does 'uname -m' give under x32, anyway?

Right now is gives x86_64, but that should probably be changed before
mainlining.

	-hpa
-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 22:21                                           ` Arnaud Lacombe
@ 2011-07-30 22:57                                             ` David Woodhouse
  0 siblings, 0 replies; 34+ messages in thread
From: David Woodhouse @ 2011-07-30 22:57 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: H. Peter Anvin, Michal Marek, Ted Ts'o, Ingo Molnar, x86,
	linux-kernel, linux-kbuild

On Sat, 2011-07-30 at 18:21 -0400, Arnaud Lacombe wrote:
> > I'll work on a patch to fix that, and then it will be fine when the
> > default for SUBARCH changes to be "x86".
> >
> I still fail to see why you want it that way... You want both ARCH and
> SUBARCH to be 'x86' ?

See the way that SUBARCH is inferred in the Makefile, and then ARCH is
set to match it (unless ARCH is set by the user).

To change the default setting of ARCH, we actually change the inference
of *SUBARCH*. And yes, in the common case they are both the *same*; the
SUBARCH variable doesn't really do anything except work as a temporary
variable holding the default setting for ARCH.

In an ARCH=um build, of course they *are* different, and SUBARCH is
actually used for more than that.

> This starts to be a hell lots of deep changes just to fix i386 build
> under a fast x86-64 without having to specify ARCH=i386. That job
> alone can be done a lot easier. 

It's not just that. It's also about making things work properly as
config options — so we can finally complete the merge of arch/i386 and
arch/x86_64, which directories we deleted almost four years ago, into
the single 'x86' architecture.

After a few 'unrelated' cleanups to how $(SUBARCH) is handled, the patch
to make SUBARCH=x86 work in um really isn't that intrusive at all; I'll
post the sequence shortly.

We *could* preserve the legacy inference of SUBARCH={i386,x86_64} *just*
for the ARCH=um case, but I think it's better not to.

-- 
dwmw2


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30  0:49                               ` [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT David Woodhouse
  2011-07-30  1:26                                 ` Arnaud Lacombe
  2011-07-30 15:52                                 ` Arnaud Lacombe
@ 2011-07-31  5:18                                 ` Arnaud Lacombe
  2011-07-31  8:13                                   ` David Woodhouse
  2011-07-31 21:47                                 ` Arnaud Lacombe
  3 siblings, 1 reply; 34+ messages in thread
From: Arnaud Lacombe @ 2011-07-31  5:18 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

Hi,

On Fri, Jul 29, 2011 at 8:49 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> I *frequently* waste a bunch of time when I take a 32-bit .config from a
> test machine and try to build it on a faster 64-bit system, and its
> existing setting of CONFIG_64BIT=n gets *changed* to match the build host.
>
> This is because the default setting for $ARCH when discovered from
> 'uname' is one of the legacy pre-x86-merge values (i386 or x86_64),
> which effectively force the setting of CONFIG_64BIT to match. We should
> default to ARCH=x86 instead, finally completing the merge that we
> started so long ago.
>
> This patch preserves the behaviour of the legacy ARCH settings for commands
> such as:
>
>   make ARCH=x86_64 randconfig
>   make ARCH=i386 randconfig
>
> ... although since my commit "Enable 'make CONFIG_FOO=y oldconfig'" those
> would be better expressed as:
>
>   make CONFIG_64BIT=y randconfig
>   make CONFIG_64BIT=n randconfig
>
> ... since that is a more generic way to set *any* config option, and
> there's no other technical reason to keep the legacy ARCH values around
> any more just to achieve that purpose; they could be removed at any
> time.
>
> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
> Link: http://lkml.kernel.org/r/1306707270.2029.377.camel@i7.infradead.org
> ---
> v2: Explicitly turn off CONFIG_64BIT in i386_defconfig. The default for
>    CONFIG_64BIT has *changed* (from n to y) for ARCH=x86, so it needs to
>    be explicitly turned off or 'make i386_defconfig' will give you 64-bit.
> v3: Same patch as before; just updated changelog.
>
>  Makefile                        |    3 ++-
>  arch/x86/Kconfig                |    2 +-
>  arch/x86/Makefile               |    4 ++++
>  arch/x86/configs/i386_defconfig |    1 +
>  4 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index d018956..303df9b 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 153aa6f..9467fdd 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"
If I'm reading this correctly, does this mean that someone doing an
'allyesconfig' on an i386 machine will get a configuration for a
64bits kernel[0] ? With your logic, you would require the user to
manually specify CONFIG_64BIT=n, which should be automatic on such a
system...

This logic seems broken to me.

 - Arnaud

[0]: both ARCH and SUBARCH will be x86, so the conditional will translate to 'y'

>        ---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
> diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig
> index 2bf18059f..5f96c1c 100644
> --- a/arch/x86/configs/i386_defconfig
> +++ b/arch/x86/configs/i386_defconfig
> @@ -1,3 +1,4 @@
> +# CONFIG_64BIT is not set
>  CONFIG_EXPERIMENTAL=y
>  # CONFIG_LOCALVERSION_AUTO is not set
>  CONFIG_SYSVIPC=y
> --
> 1.7.6
>
>
>
> --
> dwmw2
>
>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-31  5:18                                 ` Arnaud Lacombe
@ 2011-07-31  8:13                                   ` David Woodhouse
  0 siblings, 0 replies; 34+ messages in thread
From: David Woodhouse @ 2011-07-31  8:13 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

On Sun, 2011-07-31 at 01:18 -0400, Arnaud Lacombe wrote:
> If I'm reading this correctly, does this mean that someone doing an
> 'allyesconfig' on an i386 machine will get a configuration for a
> 64bits kernel[0] ? With your logic, you would require the user to
> manually specify CONFIG_64BIT=n, which should be automatic on such a
> system... 

Yes, that is entirely correct, and intentional. If the user asks for
'all yes', then the user gets 'all yes'.

We do not attempt some kind of half-baked Aunt Tillie mode where we
guess certain settings from the build host.

It's not as if people often use 'allyesconfig' to build kernels they're
actually going to *run*.

-- 
dwmw2


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30 15:52                                 ` Arnaud Lacombe
  2011-07-30 16:19                                   ` David Woodhouse
@ 2011-07-31 19:40                                   ` Arnaud Lacombe
  2011-07-31 20:00                                     ` David Woodhouse
  1 sibling, 1 reply; 34+ messages in thread
From: Arnaud Lacombe @ 2011-07-31 19:40 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

Hi,

On Sat, Jul 30, 2011 at 11:52 AM, Arnaud Lacombe <lacombar@gmail.com> wrote:
> Hi,
>
> On Fri, Jul 29, 2011 at 8:49 PM, David Woodhouse <dwmw2@infradead.org> wrote:
>> I *frequently* waste a bunch of time when I take a 32-bit .config from a
>> test machine and try to build it on a faster 64-bit system, and its
>> existing setting of CONFIG_64BIT=n gets *changed* to match the build host.
>>
>> This is because the default setting for $ARCH when discovered from
>> 'uname' is one of the legacy pre-x86-merge values (i386 or x86_64),
>> which effectively force the setting of CONFIG_64BIT to match. We should
>> default to ARCH=x86 instead, finally completing the merge that we
>> started so long ago.
>>
>> This patch preserves the behaviour of the legacy ARCH settings for commands
>> such as:
>>
>>   make ARCH=x86_64 randconfig
>>   make ARCH=i386 randconfig
>>
>> ... although since my commit "Enable 'make CONFIG_FOO=y oldconfig'" those
>> would be better expressed as:
>>
>>   make CONFIG_64BIT=y randconfig
>>   make CONFIG_64BIT=n randconfig
>>
>> ... since that is a more generic way to set *any* config option, and
>> there's no other technical reason to keep the legacy ARCH values around
>> any more just to achieve that purpose; they could be removed at any
>> time.
>>
>> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
>> Link: http://lkml.kernel.org/r/1306707270.2029.377.camel@i7.infradead.org
>> ---
>> v2: Explicitly turn off CONFIG_64BIT in i386_defconfig. The default for
>>    CONFIG_64BIT has *changed* (from n to y) for ARCH=x86, so it needs to
>>    be explicitly turned off or 'make i386_defconfig' will give you 64-bit.
>> v3: Same patch as before; just updated changelog.
>>
>>  Makefile                        |    3 ++-
>>  arch/x86/Kconfig                |    2 +-
>>  arch/x86/Makefile               |    4 ++++
>>  arch/x86/configs/i386_defconfig |    1 +
>>  4 files changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index d018956..303df9b 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/ \
> this is breaking ARCH=um.
>
FWIW, you are still breaking `scripts/checkstack.pl',
`scripts/tags.sh' (all UML related) and this change will lead users of
ARCH=i386 to trigger the cross-compile mode of modpost introduced in
4ce6efed48d736e3384c39ff87bda723e1f8e041.

 - Arnaud

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-31 19:40                                   ` Arnaud Lacombe
@ 2011-07-31 20:00                                     ` David Woodhouse
  2011-07-31 20:24                                       ` Arnaud Lacombe
  0 siblings, 1 reply; 34+ messages in thread
From: David Woodhouse @ 2011-07-31 20:00 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

On Sun, 2011-07-31 at 15:40 -0400, Arnaud Lacombe wrote:
> FWIW, you are still breaking `scripts/checkstack.pl',
> `scripts/tags.sh' (all UML related)

Can you explain the nature of the breakage? It's probably also easy to
fix (or was already arguably broken), but it would be helpful if you'd
point at what you think is wrong rather than making me guess.

>  and this change will lead users of ARCH=i386 to trigger the
> cross-compile mode of modpost introduced in
> 4ce6efed48d736e3384c39ff87bda723e1f8e041.

That doesn't seem unreasonable. After all, if the .config values are no
longer being forcibly overridden to match the build host, you no longer
*need* to add ARCH=i386 on the command line just to make the build
system honour your existing configuration with CONFIG_64BIT=n. So
there's absolutely no point in having ARCH=i386 there. If you want the
more stringent checks, don't do that then. But I'll take a look at this
too. Thanks for actually giving enough detail.

-- 
dwmw2


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-31 20:00                                     ` David Woodhouse
@ 2011-07-31 20:24                                       ` Arnaud Lacombe
  2011-07-31 20:51                                         ` David Woodhouse
  0 siblings, 1 reply; 34+ messages in thread
From: Arnaud Lacombe @ 2011-07-31 20:24 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

Hi,

On Sun, Jul 31, 2011 at 4:00 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> On Sun, 2011-07-31 at 15:40 -0400, Arnaud Lacombe wrote:
>> FWIW, you are still breaking `scripts/checkstack.pl',
>> `scripts/tags.sh' (all UML related)
>
> Can you explain the nature of the breakage? It's probably also easy to
> fix (or was already arguably broken), but it would be helpful if you'd
> point at what you think is wrong rather than making me guess.
>
scripts/tags.sh:
[...]
# Support um (which uses SUBARCH)
if [ "${ARCH}" = "um" ]; then
        if [ "$SUBARCH" = "i386" ]; then
                archinclude=x86
        elif [ "$SUBARCH" = "x86_64" ]; then
                archinclude=x86
        else
                archinclude=${SUBARCH}
        fi
fi

So this one is not broken, but the conditionals are deadcode. I wonder
if it should not just use ${SRCARCH}.

Makefile:
ifeq ($(ARCH), um)
CHECKSTACK_ARCH := $(SUBARCH)
else
CHECKSTACK_ARCH := $(ARCH)
endif
checkstack:
        $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
        $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH)

scripts/checkstack.pl:
my (@stack, $re, $dre, $x, $xs);
{
        my $arch = shift;
        if ($arch eq "") {
                $arch = `uname -m`;
                chomp($arch);
        }
[...]
        } elsif ($arch eq 'x86_64') {
                #    2f60:      48 81 ec e8 05 00 00    sub    $0x5e8,%rsp
                $re = qr/^.*[as][du][db]    \$(0x$x{1,8}),\%rsp$/o;
                $dre = qr/^.*[as][du][db]    (\%.*),\%rsp$/o;

this one actually is broken:

% perl scripts/checkstack.pl x86
wrong or unknown architecture "x86"

 - Arnaud

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-31 20:24                                       ` Arnaud Lacombe
@ 2011-07-31 20:51                                         ` David Woodhouse
  0 siblings, 0 replies; 34+ messages in thread
From: David Woodhouse @ 2011-07-31 20:51 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

On Sun, 2011-07-31 at 16:24 -0400, Arnaud Lacombe wrote:
> Hi,
> 
> On Sun, Jul 31, 2011 at 4:00 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> > On Sun, 2011-07-31 at 15:40 -0400, Arnaud Lacombe wrote:
> >> FWIW, you are still breaking `scripts/checkstack.pl',
> >> `scripts/tags.sh' (all UML related)
> >
> > Can you explain the nature of the breakage? It's probably also easy to
> > fix (or was already arguably broken), but it would be helpful if you'd
> > point at what you think is wrong rather than making me guess.
> >
> scripts/tags.sh:
> [...]
> # Support um (which uses SUBARCH)
> if [ "${ARCH}" = "um" ]; then
>         if [ "$SUBARCH" = "i386" ]; then
>                 archinclude=x86
>         elif [ "$SUBARCH" = "x86_64" ]; then
>                 archinclude=x86
>         else
>                 archinclude=${SUBARCH}
>         fi
> fi
> 
> So this one is not broken, but the conditionals are deadcode. I wonder
> if it should not just use ${SRCARCH}.

Ah yes, I'd actually looked at that one yesterday since I saw it
referenced from somewhere in the um code that I was looking at. It's not
*quite* deadcode yet — remember, we're not talking about *removing* the
legacy ARCH=i386 and ARCH=x86_64 yet; just making them no longer the
*default*, and making ARCH=x86 the default instead (when on an x86 box).

There are three phases, which we've been through for the various other
architectures that merged 32 and 64 bit code already:

 1. Make ARCH=x86 work.
 2. Make ARCH=x86 the default.
 3. Remove the legacy ARCH= values.

We *thought* we'd fairly much finished #1 in 2007, with commit
208652d6... but evidently there are a couple of things we still need to
fix. As I said, thanks for helping to find those.

My patch is doing #2, since it seems the best and cleanest way to fix
the bug that keeps biting. It's not only "a" fix; it's the *right* thing
to do.

I'm not touching #3 yet; people are still clinging to the old crap as if
the world will end if they have to type 'make CONFIG_64BIT=n oldconfig'
instead of 'make ARCH=i386 oldconfig', because the extra few characters
will give them RSI and then they'll have to quit their nice computer job
and then they'll have to sell their body to make ends meet. Or something
like that. But I'm making the CONFIG_64BIT=n thing work anyway :)



> Makefile:
> ifeq ($(ARCH), um)
> CHECKSTACK_ARCH := $(SUBARCH)
> else
> CHECKSTACK_ARCH := $(ARCH)
> endif
> checkstack:
>         $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
>         $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
> 
> scripts/checkstack.pl:
> my (@stack, $re, $dre, $x, $xs);
> {
>         my $arch = shift;
>         if ($arch eq "") {
>                 $arch = `uname -m`;
>                 chomp($arch);
>         }
> [...]
>         } elsif ($arch eq 'x86_64') {
>                 #    2f60:      48 81 ec e8 05 00 00    sub    $0x5e8,%rsp
>                 $re = qr/^.*[as][du][db]    \$(0x$x{1,8}),\%rsp$/o;
>                 $dre = qr/^.*[as][du][db]    (\%.*),\%rsp$/o;
> 
> this one actually is broken:
> 
> % perl scripts/checkstack.pl x86
> wrong or unknown architecture "x86"

OK, I'll go poke at that; it definitely *should* have been working and
could be considered 'broken' since 2007. It's part of phase 1.

This should probably fix it.... I'll test a bit more and send a real
patch. Thanks for pointing it out.

diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index 17e3843..2c5c869 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -59,6 +59,10 @@ my (@stack, $re, $dre, $x, $xs);
 		#    2f60:	48 81 ec e8 05 00 00 	sub    $0x5e8,%rsp
 		$re = qr/^.*[as][du][db]    \$(0x$x{1,8}),\%rsp$/o;
 		$dre = qr/^.*[as][du][db]    (\%.*),\%rsp$/o;
+	} elsif ($arch eq 'x86') {
+		#    2f60:	48 81 ec e8 05 00 00 	sub    $0x5e8,%rsp
+		$re = qr/^.*[as][du][db]    \$(0x$x{1,8}),\%[er]sp$/o;
+		$dre = qr/^.*[as][du][db]    (\%.*),\%[er]sp$/o;
 	} elsif ($arch eq 'ia64') {
 		#e0000000044011fc:       01 0f fc 8c     adds r12=-384,r12
 		$re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o;


-- 
dwmw2


^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-30  0:49                               ` [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT David Woodhouse
                                                   ` (2 preceding siblings ...)
  2011-07-31  5:18                                 ` Arnaud Lacombe
@ 2011-07-31 21:47                                 ` Arnaud Lacombe
  2011-07-31 21:51                                   ` Arnaud Lacombe
  3 siblings, 1 reply; 34+ messages in thread
From: Arnaud Lacombe @ 2011-07-31 21:47 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

Hi,

On Fri, Jul 29, 2011 at 8:49 PM, David Woodhouse <dwmw2@infradead.org> wrote:
> I *frequently* waste a bunch of time when I take a 32-bit .config from a
> test machine and try to build it on a faster 64-bit system, and its
> existing setting of CONFIG_64BIT=n gets *changed* to match the build host.
>
> This is because the default setting for $ARCH when discovered from
> 'uname' is one of the legacy pre-x86-merge values (i386 or x86_64),
> which effectively force the setting of CONFIG_64BIT to match. We should
> default to ARCH=x86 instead, finally completing the merge that we
> started so long ago.
>
AFAICS, `scripts/mkcompile_h' ends up using ${ARCH} to build
UTS_MACHINE, so it ends up being directly visible to userland. I would
wonder which userland application (both script and binaries), relying
on this interface, you are breaking...

 - Arnaud

> This patch preserves the behaviour of the legacy ARCH settings for commands
> such as:
>
>   make ARCH=x86_64 randconfig
>   make ARCH=i386 randconfig
>
> ... although since my commit "Enable 'make CONFIG_FOO=y oldconfig'" those
> would be better expressed as:
>
>   make CONFIG_64BIT=y randconfig
>   make CONFIG_64BIT=n randconfig
>
> ... since that is a more generic way to set *any* config option, and
> there's no other technical reason to keep the legacy ARCH values around
> any more just to achieve that purpose; they could be removed at any
> time.
>
> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
> Link: http://lkml.kernel.org/r/1306707270.2029.377.camel@i7.infradead.org
> ---
> v2: Explicitly turn off CONFIG_64BIT in i386_defconfig. The default for
>    CONFIG_64BIT has *changed* (from n to y) for ARCH=x86, so it needs to
>    be explicitly turned off or 'make i386_defconfig' will give you 64-bit.
> v3: Same patch as before; just updated changelog.
>
>  Makefile                        |    3 ++-
>  arch/x86/Kconfig                |    2 +-
>  arch/x86/Makefile               |    4 ++++
>  arch/x86/configs/i386_defconfig |    1 +
>  4 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index d018956..303df9b 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 153aa6f..9467fdd 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
> diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig
> index 2bf18059f..5f96c1c 100644
> --- a/arch/x86/configs/i386_defconfig
> +++ b/arch/x86/configs/i386_defconfig
> @@ -1,3 +1,4 @@
> +# CONFIG_64BIT is not set
>  CONFIG_EXPERIMENTAL=y
>  # CONFIG_LOCALVERSION_AUTO is not set
>  CONFIG_SYSVIPC=y
> --
> 1.7.6
>
>
>
> --
> dwmw2
>
>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT
  2011-07-31 21:47                                 ` Arnaud Lacombe
@ 2011-07-31 21:51                                   ` Arnaud Lacombe
  0 siblings, 0 replies; 34+ messages in thread
From: Arnaud Lacombe @ 2011-07-31 21:51 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Michal Marek, Ted Ts'o, Ingo Molnar, x86, linux-kernel,
	linux-kbuild, hpa

On Sun, Jul 31, 2011 at 5:47 PM, Arnaud Lacombe <lacombar@gmail.com> wrote:
> Hi,
>
> On Fri, Jul 29, 2011 at 8:49 PM, David Woodhouse <dwmw2@infradead.org> wrote:
>> I *frequently* waste a bunch of time when I take a 32-bit .config from a
>> test machine and try to build it on a faster 64-bit system, and its
>> existing setting of CONFIG_64BIT=n gets *changed* to match the build host.
>>
>> This is because the default setting for $ARCH when discovered from
>> 'uname' is one of the legacy pre-x86-merge values (i386 or x86_64),
>> which effectively force the setting of CONFIG_64BIT to match. We should
>> default to ARCH=x86 instead, finally completing the merge that we
>> started so long ago.
>>
> AFAICS, `scripts/mkcompile_h' ends up using ${ARCH} to build
> UTS_MACHINE, so it ends up being directly visible to userland. I would
> wonder which userland application (both script and binaries), relying
> on this interface, you are breaking...
>
my bad, mkcompile_h uses an UTS_MACHINE variable defined by the
arch/x86/Makefile.

 - Arnaud

>  - Arnaud
>
>> This patch preserves the behaviour of the legacy ARCH settings for commands
>> such as:
>>
>>   make ARCH=x86_64 randconfig
>>   make ARCH=i386 randconfig
>>
>> ... although since my commit "Enable 'make CONFIG_FOO=y oldconfig'" those
>> would be better expressed as:
>>
>>   make CONFIG_64BIT=y randconfig
>>   make CONFIG_64BIT=n randconfig
>>
>> ... since that is a more generic way to set *any* config option, and
>> there's no other technical reason to keep the legacy ARCH values around
>> any more just to achieve that purpose; they could be removed at any
>> time.
>>
>> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
>> Link: http://lkml.kernel.org/r/1306707270.2029.377.camel@i7.infradead.org
>> ---
>> v2: Explicitly turn off CONFIG_64BIT in i386_defconfig. The default for
>>    CONFIG_64BIT has *changed* (from n to y) for ARCH=x86, so it needs to
>>    be explicitly turned off or 'make i386_defconfig' will give you 64-bit.
>> v3: Same patch as before; just updated changelog.
>>
>>  Makefile                        |    3 ++-
>>  arch/x86/Kconfig                |    2 +-
>>  arch/x86/Makefile               |    4 ++++
>>  arch/x86/configs/i386_defconfig |    1 +
>>  4 files changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index d018956..303df9b 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 153aa6f..9467fdd 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
>> diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig
>> index 2bf18059f..5f96c1c 100644
>> --- a/arch/x86/configs/i386_defconfig
>> +++ b/arch/x86/configs/i386_defconfig
>> @@ -1,3 +1,4 @@
>> +# CONFIG_64BIT is not set
>>  CONFIG_EXPERIMENTAL=y
>>  # CONFIG_LOCALVERSION_AUTO is not set
>>  CONFIG_SYSVIPC=y
>> --
>> 1.7.6
>>
>>
>>
>> --
>> dwmw2
>>
>>
>

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2011-07-31 21:51 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1306707270.2029.377.camel@i7.infradead.org>
     [not found] ` <201105301305.59166.arnd@arndb.de>
     [not found]   ` <20110530102731.fa9fbc4a.rdunlap@xenotime.net>
     [not found]     ` <201105302040.55509.arnd@arndb.de>
2011-05-30 20:01       ` [PATCH] Fix corruption of CONFIG_X86_32 in 'make oldconfig' Randy Dunlap
     [not found] ` <20110530072300.GA9802@elte.hu>
     [not found]   ` <1306745835.2029.389.camel@i7.infradead.org>
     [not found]     ` <20110530104231.GF17821@elte.hu>
     [not found]       ` <20110530104656.GA19532@elte.hu>
     [not found]         ` <E934876C-FABB-41F8-8C5E-469AA42DBE91@mit.edu>
     [not found]           ` <20110530105809.GA20133@elte.hu>
     [not found]             ` <1A4DB87D-9B32-44C0-B7C9-47A003CABD96@mit.edu>
     [not found]               ` <alpine.LFD.2.02.1105301955210.3164@localhost6.localdomain6>
     [not found]                 ` <20110530195545.GG2890@dhcp-172-31-194-241.cam.corp.google.com>
     [not found]                   ` <alpine.LFD.2.02.1105302103220.3164@localhost6.localdomain6>
2011-05-30 22:39                     ` [PATCH] Enable 'make CONFIG_FOO=y oldconfig' David Woodhouse
2011-05-31  0:24                       ` Arnaud Lacombe
2011-05-31 15:48                         ` David Woodhouse
2011-05-31 16:12                           ` Arnaud Lacombe
2011-06-24 13:49                             ` Michal Marek
2011-07-29 23:32                               ` [PATCH v2] " David Woodhouse
2011-07-30  1:15                                 ` Arnaud Lacombe
2011-07-30  9:04                                   ` David Woodhouse
2011-07-30  0:49                               ` [PATCH v3] x86, kconfig: Default to ARCH=x86 to avoid overriding CONFIG_64BIT David Woodhouse
2011-07-30  1:26                                 ` Arnaud Lacombe
2011-07-30  8:37                                   ` David Woodhouse
2011-07-30 15:21                                     ` Arnaud Lacombe
2011-07-30 15:52                                 ` Arnaud Lacombe
2011-07-30 16:19                                   ` David Woodhouse
2011-07-30 16:33                                     ` Arnaud Lacombe
2011-07-30 18:59                                       ` H. Peter Anvin
2011-07-30 20:58                                         ` David Woodhouse
2011-07-30 22:03                                           ` H. Peter Anvin
2011-07-30 22:17                                             ` David Woodhouse
2011-07-30 22:21                                               ` H. Peter Anvin
2011-07-30 22:24                                               ` Arnaud Lacombe
2011-07-30 22:34                                                 ` David Woodhouse
2011-07-30 22:39                                                   ` H. Peter Anvin
2011-07-30 22:21                                           ` Arnaud Lacombe
2011-07-30 22:57                                             ` David Woodhouse
2011-07-31 19:40                                   ` Arnaud Lacombe
2011-07-31 20:00                                     ` David Woodhouse
2011-07-31 20:24                                       ` Arnaud Lacombe
2011-07-31 20:51                                         ` David Woodhouse
2011-07-31  5:18                                 ` Arnaud Lacombe
2011-07-31  8:13                                   ` David Woodhouse
2011-07-31 21:47                                 ` Arnaud Lacombe
2011-07-31 21:51                                   ` Arnaud Lacombe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox