]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/kbuild/64: Test for the availability of the -mtune=native compiler flag
authorIngo Molnar <mingo@kernel.org>
Mon, 24 Mar 2025 07:05:19 +0000 (08:05 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 25 Mar 2025 07:24:06 +0000 (08:24 +0100)
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 <sfr@canb.auug.org.au>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Stephen Rothwell <sfr@canb.auug.org.au> # build test
Cc: Tor Vic <torvic9@mailbox.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250324172723.49fb0416@canb.auug.org.au
arch/x86/Kconfig.cpu

index 9d108a54c30a61511bb61fecb0aadd96cd9bd77c..87bede96e8009ef3380613748f1b1f65eec3fef9 100644 (file)
@@ -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