Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* [PATCH] kbuild: improve sanity check for ARCH variable on x86
@ 2026-10-20  0:17 Cao Jin
  2026-10-20  0:36 ` Nathan Chancellor
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Cao Jin @ 2026-10-20  0:17 UTC (permalink / raw)
  To: nathan, nsc; +Cc: linux-kbuild, Cao Jin

When building for x86, ARCH=i{4,5,6}86 and x86_32 will fail the build.
Make it catch all name variants.
---
 Makefile | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 7c855e6fe544..cd397027891a 100644
--- a/Makefile
+++ b/Makefile
@@ -409,12 +409,10 @@ ARCH		?= $(SUBARCH)
 UTS_MACHINE 	:= $(ARCH)
 SRCARCH 	:= $(ARCH)
 
-# Additional ARCH settings for x86
-ifeq ($(ARCH),i386)
-        SRCARCH := x86
-endif
-ifeq ($(ARCH),x86_64)
-        SRCARCH := x86
+# Additional sanity check for cmdline ARCH settings for x86. This catch
+# more name variants than "i386" and "x86_64".
+ifneq ($(findstring 86,$(ARCH)),)
+    SRCARCH := x86
 endif
 
 # Additional ARCH settings for sparc
-- 
2.55.0


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

* Re: [PATCH] kbuild: improve sanity check for ARCH variable on x86
  2026-10-20  0:17 [PATCH] kbuild: improve sanity check for ARCH variable on x86 Cao Jin
@ 2026-10-20  0:36 ` Nathan Chancellor
  2026-10-20  0:59   ` Borislav Petkov
  2026-10-20  1:33   ` Cao Jin
  2026-10-20  1:38 ` Randy Dunlap
  2026-10-21  0:17 ` sashiko-bot
  2 siblings, 2 replies; 9+ messages in thread
From: Nathan Chancellor @ 2026-10-20  0:36 UTC (permalink / raw)
  To: Cao Jin; +Cc: nsc, linux-kbuild, x86

On Mon, Oct 19, 2026 at 05:17:38PM -0700, Cao Jin wrote:
> When building for x86, ARCH=i{4,5,6}86 and x86_32 will fail the build.

Thanks for the patch. Where is it documented that these other options
are valid? It seems like this is just expected behavior because these
are not valid values for setting ARCH for x86. At the very least, I
think something like this needs to be acked by the x86 folks.

> Make it catch all name variants.

You are missing a sign off.

> ---
>  Makefile | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 7c855e6fe544..cd397027891a 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -409,12 +409,10 @@ ARCH		?= $(SUBARCH)
>  UTS_MACHINE 	:= $(ARCH)
>  SRCARCH 	:= $(ARCH)
>  
> -# Additional ARCH settings for x86
> -ifeq ($(ARCH),i386)
> -        SRCARCH := x86
> -endif
> -ifeq ($(ARCH),x86_64)
> -        SRCARCH := x86
> +# Additional sanity check for cmdline ARCH settings for x86. This catch
> +# more name variants than "i386" and "x86_64".
> +ifneq ($(findstring 86,$(ARCH)),)
> +    SRCARCH := x86
>  endif
>  
>  # Additional ARCH settings for sparc
> -- 
> 2.55.0
> 

-- 
Cheers,
Nathan

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

* Re: [PATCH] kbuild: improve sanity check for ARCH variable on x86
  2026-10-20  0:36 ` Nathan Chancellor
@ 2026-10-20  0:59   ` Borislav Petkov
  2026-10-20  1:26     ` Cao Jin
  2026-10-20  1:33   ` Cao Jin
  1 sibling, 1 reply; 9+ messages in thread
From: Borislav Petkov @ 2026-10-20  0:59 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: Cao Jin, nsc, linux-kbuild, x86

On Mon, Oct 19, 2026 at 05:36:25PM -0700, Nathan Chancellor wrote:
> On Mon, Oct 19, 2026 at 05:17:38PM -0700, Cao Jin wrote:
> > When building for x86, ARCH=i{4,5,6}86 and x86_32 will fail the build.
> 
> Thanks for the patch. Where is it documented that these other options
> are valid? It seems like this is just expected behavior because these
> are not valid values for setting ARCH for x86. At the very least, I
> think something like this needs to be acked by the x86 folks.

I hardly doubt that it'll ever be without a proper explanation why.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

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

* Re: [PATCH] kbuild: improve sanity check for ARCH variable on x86
  2026-10-20  0:59   ` Borislav Petkov
@ 2026-10-20  1:26     ` Cao Jin
  0 siblings, 0 replies; 9+ messages in thread
From: Cao Jin @ 2026-10-20  1:26 UTC (permalink / raw)
  To: Borislav Petkov, Nathan Chancellor; +Cc: nsc, linux-kbuild, x86

Thank you both for prompt response.

I don't think there is document for it, and my rule of thumb tell me 
that all of i{3,4,5,6}86 & x86_32 represent 32-bit x86(unless I am 
wrong). A young developer may try any of those values at cmdline when 
building 32-bit x86 if he doesn't know the nuance among these value.

On 10/19/26 5:59 PM, Borislav Petkov wrote:
> On Mon, Oct 19, 2026 at 05:36:25PM -0700, Nathan Chancellor wrote:
>> On Mon, Oct 19, 2026 at 05:17:38PM -0700, Cao Jin wrote:
>>> When building for x86, ARCH=i{4,5,6}86 and x86_32 will fail the build.
>>
>> Thanks for the patch. Where is it documented that these other options
>> are valid? It seems like this is just expected behavior because these
>> are not valid values for setting ARCH for x86. At the very least, I
>> think something like this needs to be acked by the x86 folks.
> 
> I hardly doubt that it'll ever be without a proper explanation why.
> 


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

* Re: [PATCH] kbuild: improve sanity check for ARCH variable on x86
  2026-10-20  0:36 ` Nathan Chancellor
  2026-10-20  0:59   ` Borislav Petkov
@ 2026-10-20  1:33   ` Cao Jin
  2026-10-20  1:39     ` Randy Dunlap
  1 sibling, 1 reply; 9+ messages in thread
From: Cao Jin @ 2026-10-20  1:33 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: nsc, linux-kbuild, x86



On 10/19/26 5:36 PM, Nathan Chancellor wrote:
> On Mon, Oct 19, 2026 at 05:17:38PM -0700, Cao Jin wrote:
>> When building for x86, ARCH=i{4,5,6}86 and x86_32 will fail the build.
> 
> Thanks for the patch. Where is it documented that these other options
> are valid? It seems like this is just expected behavior because these
> are not valid values for setting ARCH for x86. At the very least, I
> think something like this needs to be acked by the x86 folks.
> 

Forget to mention, "i386" & "x86_64" are not valid value for ARCH for 
x86 either, the top Makefile correct them to "x86". So we may want to 
correct all other possible invalid value for x86 ARCH, if my 
understanding of i{3,4,5,6}86 are the same for 32-bit x86 were right.


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

* Re: [PATCH] kbuild: improve sanity check for ARCH variable on x86
  2026-10-20  0:17 [PATCH] kbuild: improve sanity check for ARCH variable on x86 Cao Jin
  2026-10-20  0:36 ` Nathan Chancellor
@ 2026-10-20  1:38 ` Randy Dunlap
  2026-10-20  1:51   ` Cao Jin
  2026-10-21  0:17 ` sashiko-bot
  2 siblings, 1 reply; 9+ messages in thread
From: Randy Dunlap @ 2026-10-20  1:38 UTC (permalink / raw)
  To: Cao Jin, nathan, nsc; +Cc: linux-kbuild



On 10/19/26 5:17 PM, Cao Jin wrote:
> When building for x86, ARCH=i{4,5,6}86 and x86_32 will fail the build.
> Make it catch all name variants.
> ---
>  Makefile | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 7c855e6fe544..cd397027891a 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -409,12 +409,10 @@ ARCH		?= $(SUBARCH)
>  UTS_MACHINE 	:= $(ARCH)
>  SRCARCH 	:= $(ARCH)
>  
> -# Additional ARCH settings for x86
> -ifeq ($(ARCH),i386)
> -        SRCARCH := x86
> -endif
> -ifeq ($(ARCH),x86_64)
> -        SRCARCH := x86
> +# Additional sanity check for cmdline ARCH settings for x86. This catch
> +# more name variants than "i386" and "x86_64".
> +ifneq ($(findstring 86,$(ARCH)),)
> +    SRCARCH := x86
>  endif
>  
>  # Additional ARCH settings for sparc

From Documentation/kbuild/kbuild.rst:

ARCH
----
Set ARCH to the architecture to be built.

In most cases the name of the architecture is the same as the
directory name found in the arch/ directory.

But some architectures such as x86 and sparc have aliases.

- x86: i386 for 32 bit, x86_64 for 64 bit
- parisc: parisc64 for 64 bit
- sparc: sparc32 for 32 bit, sparc64 for 64 bit

-- 
~Randy


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

* Re: [PATCH] kbuild: improve sanity check for ARCH variable on x86
  2026-10-20  1:33   ` Cao Jin
@ 2026-10-20  1:39     ` Randy Dunlap
  0 siblings, 0 replies; 9+ messages in thread
From: Randy Dunlap @ 2026-10-20  1:39 UTC (permalink / raw)
  To: Cao Jin, Nathan Chancellor; +Cc: nsc, linux-kbuild, x86



On 10/19/26 6:33 PM, Cao Jin wrote:
> 
> 
> On 10/19/26 5:36 PM, Nathan Chancellor wrote:
>> On Mon, Oct 19, 2026 at 05:17:38PM -0700, Cao Jin wrote:
>>> When building for x86, ARCH=i{4,5,6}86 and x86_32 will fail the build.
>>
>> Thanks for the patch. Where is it documented that these other options
>> are valid? It seems like this is just expected behavior because these
>> are not valid values for setting ARCH for x86. At the very least, I
>> think something like this needs to be acked by the x86 folks.
>>
> 
> Forget to mention, "i386" & "x86_64" are not valid value for ARCH for x86 either, the top Makefile correct them to "x86". So we may want to correct all other possible invalid value for x86 ARCH, if my understanding of i{3,4,5,6}86 are the same for 32-bit x86 were right.

They are documented aliases for x86.

-- 
~Randy


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

* Re: [PATCH] kbuild: improve sanity check for ARCH variable on x86
  2026-10-20  1:38 ` Randy Dunlap
@ 2026-10-20  1:51   ` Cao Jin
  0 siblings, 0 replies; 9+ messages in thread
From: Cao Jin @ 2026-10-20  1:51 UTC (permalink / raw)
  To: Randy Dunlap, nathan, nsc; +Cc: linux-kbuild



On 10/19/26 6:38 PM, Randy Dunlap wrote:
> 

> 
>  From Documentation/kbuild/kbuild.rst:
> 
> ARCH
> ----
> Set ARCH to the architecture to be built.
> 
> In most cases the name of the architecture is the same as the
> directory name found in the arch/ directory.
> 
> But some architectures such as x86 and sparc have aliases.
> 
> - x86: i386 for 32 bit, x86_64 for 64 bit
> - parisc: parisc64 for 64 bit
> - sparc: sparc32 for 32 bit, sparc64 for 64 bit
> 
I see. Thank you.
Sorry for the noise.

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

* Re: [PATCH] kbuild: improve sanity check for ARCH variable on x86
  2026-10-20  0:17 [PATCH] kbuild: improve sanity check for ARCH variable on x86 Cao Jin
  2026-10-20  0:36 ` Nathan Chancellor
  2026-10-20  1:38 ` Randy Dunlap
@ 2026-10-21  0:17 ` sashiko-bot
  2 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-10-21  0:17 UTC (permalink / raw)
  To: Cao Jin, nathan, nsc; +Cc: linux-kbuild

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] kbuild: unnormalized x86 ARCH variants force 64BIT and break defconfig
--

commit 3a5958b43dbec65a7ac36420afb7bc18b48749a2
Author: Cao Jin <pino.cao2022@gmail.com>

kbuild: improve sanity check for ARCH variable on x86

This commit replaces the explicit i386 and x86_64 checks in the top-level
Makefile with a findstring check matching "86" to set SRCARCH := x86 for
additional x86 architecture name variants such as i486, i586, i686, and
x86_32.

> diff --git a/Makefile b/Makefile
> index 8d23af898d44d..a32e20a8d41dd 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -410,12 +410,10 @@ ARCH		?= $(SUBARCH)
>  UTS_MACHINE 	:= $(ARCH)
>  SRCARCH 	:= $(ARCH)
>  
> -# Additional ARCH settings for x86
> -ifeq ($(ARCH),i386)
> -        SRCARCH := x86
> -endif
> -ifeq ($(ARCH),x86_64)
> -        SRCARCH := x86
> +# Additional sanity check for cmdline ARCH settings for x86. This catch
> +# more name variants than "i386" and "x86_64".
> +ifneq ($(findstring 86,$(ARCH)),)
> +    SRCARCH := x86
>  endif

[Severity: Medium]
When make is invoked with ARCH=i486, ARCH=i586, ARCH=i686, or ARCH=x86_32,
setting SRCARCH := x86 leaves $(ARCH) unnormalized for downstream x86 build
files.

In arch/x86/Kconfig, the 64BIT symbol checks $(ARCH) directly:

config 64BIT
	bool "64-bit kernel" if "$(ARCH)" = "x86"
	default "$(ARCH)" != "i386"

Because $(ARCH) is neither "x86" nor "i386" for i486, i586, i686, and
x86_32, the prompt condition evaluates to false and the default expression
evaluates to y. Doesn't this force an unconfigurable 64-bit (CONFIG_64BIT=y,
CONFIG_X86_64=y) build when one of these 32-bit x86 ARCH variants is
requested?

Similarly, arch/x86/Makefile selects KBUILD_DEFCONFIG using $(ARCH):

ifeq ($(ARCH),x86)
  ifeq ($(shell uname -m | sed -e 's/i.86/i386/'),i386)
        KBUILD_DEFCONFIG := i386_defconfig
  else
        KBUILD_DEFCONFIG := x86_64_defconfig
  endif
else
        KBUILD_DEFCONFIG := $(ARCH)_defconfig
endif

Since arch/x86/configs/ only provides i386_defconfig and x86_64_defconfig,
won't running defconfig with ARCH=i486, ARCH=i586, ARCH=i686, or
ARCH=x86_32 still fail trying to find arch/x86/configs/$(ARCH)_defconfig?

>  
>  # Additional ARCH settings for sparc

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261020001738.2607318-1-pino.cao2022@gmail.com?part=1

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

end of thread, other threads:[~2026-10-21  0:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-20  0:17 [PATCH] kbuild: improve sanity check for ARCH variable on x86 Cao Jin
2026-10-20  0:36 ` Nathan Chancellor
2026-10-20  0:59   ` Borislav Petkov
2026-10-20  1:26     ` Cao Jin
2026-10-20  1:33   ` Cao Jin
2026-10-20  1:39     ` Randy Dunlap
2026-10-20  1:38 ` Randy Dunlap
2026-10-20  1:51   ` Cao Jin
2026-10-21  0:17 ` sashiko-bot

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