From 01412081863aa81db47423d5719f2726d2a00a32 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Mon, 24 Mar 2025 08:05:19 +0100 Subject: [PATCH] x86/kbuild/64: Test for the availability of the -mtune=native compiler flag Stephen reported this build failure when cross-compiling: cc1: error: bad value 'native' for '-march=' switch Test for the availability of the -march=native flag. Reported-by: Stephen Rothwell Signed-off-by: Ingo Molnar Tested-by: Stephen Rothwell # build test Cc: Tor Vic Cc: Andy Lutomirski Cc: Brian Gerst Cc: Juergen Gross Cc: H. Peter Anvin Cc: Kees Cook Cc: Josh Poimboeuf Cc: Linus Torvalds Link: https://lore.kernel.org/r/20250324172723.49fb0416@canb.auug.org.au --- arch/x86/Kconfig.cpu | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu index 9d108a54c30a6..87bede96e8009 100644 --- a/arch/x86/Kconfig.cpu +++ b/arch/x86/Kconfig.cpu @@ -245,10 +245,14 @@ config MATOM endchoice +config CC_HAS_MARCH_NATIVE + # This flag might not be available in cross-compilers: + def_bool $(cc-option, -march=native) + config X86_NATIVE_CPU bool "Build and optimize for local/native CPU" depends on X86_64 - default n + depends on CC_HAS_MARCH_NATIVE help Optimize for the current CPU used to compile the kernel. Use this option if you intend to build the kernel for your -- 2.39.5