Re: [tip: x86/urgent] x86/build: Do not allow X86_NATIVE_CPU to be enabled when compile testing
From: Ingo Molnar
Date: Mon Nov 16 2026 - 04:40:11 EST
* tip-bot2 for Nathan Chancellor <tip-bot2@xxxxxxxxxxxxx> wrote:
> which was first added by the initial '-march=native' support in clang in 2009¹
> (other architecture drivers appear to have a similar problem). Due to the lack
> of validation that the host CPU is an x86_64 CPU, '-march=native' is expanded
> using the aarch64 host CPU's target features, which are unrecognized by the x86
> backend.
>
> While this should obviously be fixed in the compiler, this does not help
> currently released toolchains that have this issue. As a simple workaround that
> makes sense regardless of the toolchain issue, only allow CONFIG_X86_NATIVE_CPU
> to be enabled when CONFIG_COMPILE_TEST is not set (i.e., the user intends to run
> the kernel, not just build it), which will exclude it from allmodconfig.
>
> ¹https://github.com/llvm/llvm-project/commit/e13ada6a3b236f505b24501d456dec2518e4944c
>
> Fixes: ea1dcca1de12 ("x86/kbuild/64: Add the CONFIG_X86_NATIVE_CPU option to locally optimize the kernel with '-march=native'")
> Signed-off-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> Link: https://lore.kernel.org/r/20261113-x86-no-march-native-on-non-x86_64-v1-1-cbc8b096d1c4@xxxxxxxxxx
> ---
> arch/x86/Kconfig.cpu | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
> index 6e7a366..32d22cb 100644
> --- a/arch/x86/Kconfig.cpu
> +++ b/arch/x86/Kconfig.cpu
> @@ -217,6 +217,7 @@ config RUSTC_HAS_APXF
> config X86_NATIVE_CPU
> bool "Build and optimize for local/native CPU"
> depends on X86_64
> + depends on !COMPILE_TEST
I really don't like this patch. People *do* use this feature,
and it's good to have it enabled in allmodconfig.
Another problem is that this turns off most automated x86-on-x86
build testing of CONFIG_X86_NATIVE_CPU in essence, at least for the
typical configs that CI farms test, just to make much more rare
types of cross-builds a bit more convenient...
Can we just limit the feature to when host == target, ie. to not
work it around in such a crude fashion?
Thanks,
Ingo