When cross compiling x86_64 from an aarch64 machine using clang with CONFIG_X86_NATIVE_CPU enabled (such as when using allmodconfig), there may be a slew of warnings from each .c file, which makes it nearly impossible to find real issues. '+crc' is not a recognized feature for this target (ignoring feature) '+fp-armv8' is not a recognized feature for this target (ignoring feature) '+lse' is not a recognized feature for this target (ignoring feature) '+neon' is not a recognized feature for this target (ignoring feature) '+sha2' is not a recognized feature for this target (ignoring feature) '+sha3' is not a recognized feature for this target (ignoring feature) '-rand' is not a recognized feature for this target (ignoring feature) '-sme' is not a recognized feature for this target (ignoring feature) '-sme2' is not a recognized feature for this target (ignoring feature) '-sve' is not a recognized feature for this target (ignoring feature) Internally, clang expands '-march=native' into a list of target features to enable based on the detected CPU. The x86 part of the clang driver notes // FIXME: Reject attempts to use -march=native unless the target matches // the host. which was first added by the initial '-march=native' support in clang in 2009 [1] (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. Cc: stable@vger.kernel.org Fixes: ea1dcca1de12 ("x86/kbuild/64: Add the CONFIG_X86_NATIVE_CPU option to locally optimize the kernel with '-march=native'") Link: https://github.com/llvm/llvm-project/commit/e13ada6a3b236f505b24501d456dec2518e4944c [1] Signed-off-by: Nathan Chancellor --- Changes in v2: - Rather than checking if host == target, just make X86_NATIVE_CPU depend on !COMPILE_TEST, which makes sense anyways (Borislav) - Link to v1: https://patch.msgid.link/20261113-x86-no-march-native-on-non-x86_64-v1-1-cbc8b096d1c4@kernel.org --- arch/x86/Kconfig.cpu | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu index 6e7a366f0798..32d22cbf55bf 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 depends on CC_HAS_MARCH_NATIVE depends on !RUST || RUSTC_HAS_APXF help --- base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master change-id: 20261113-x86-no-march-native-on-non-x86_64-88233b48a7d7 Best regards, -- Cheers, Nathan