From: Ingo Molnar Date: Mon, 24 Mar 2025 07:05:19 +0000 (+0100) Subject: x86/kbuild/64: Test for the availability of the -mtune=native compiler flag X-Git-Tag: v6.16-rc1~191^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01412081863aa81db47423d5719f2726d2a00a32;p=thirdparty%2Fkernel%2Flinux.git 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 --- 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