[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <174368720008.30396.5633938489882625239.tip-bot2@tip-bot2>
Date: Thu, 03 Apr 2025 13:33:20 -0000
From: "tip-bot2 for Nathan Chancellor" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Nathan Chancellor <nathan@...nel.org>, Ingo Molnar <mingo@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>, Tor Vic <torvic9@...lbox.org>,
Andy Lutomirski <luto@...nel.org>, Brian Gerst <brgerst@...il.com>,
Juergen Gross <jgross@...e.com>, "H. Peter Anvin" <hpa@...or.com>,
Kees Cook <keescook@...omium.org>, Josh Poimboeuf <jpoimboe@...hat.com>,
Linus Torvalds <torvalds@...ux-foundation.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: x86/kconfig] x86/kbuild/64: Restrict clang versions that can
use '-march=native'
The following commit has been merged into the x86/kconfig branch of tip:
Commit-ID: ad9b861824ac55d81431815fffaaff5e981badc1
Gitweb: https://git.kernel.org/tip/ad9b861824ac55d81431815fffaaff5e981badc1
Author: Nathan Chancellor <nathan@...nel.org>
AuthorDate: Mon, 24 Mar 2025 20:23:00 -07:00
Committer: Ingo Molnar <mingo@...nel.org>
CommitterDate: Tue, 25 Mar 2025 08:24:06 +01:00
x86/kbuild/64: Restrict clang versions that can use '-march=native'
There are two issues that can appear when building with clang and
'-march=native'.
The first issue is a compiler crash in the ipv6 stack with clang-18,
such as when building allmodconfig. This was frequently reported on the
LLVM issue tracker:
# Link: https://github.com/llvm/llvm-project/issues?q=is%3Aissue%20ip6_rcv_core
Stack dump:
0. Program arguments: clang ... -march=native ... net/ipv6/ip6_input.c
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'net/ipv6/ip6_input.c'.
4. Running pass 'X86 DAG->DAG Instruction Selection' on function '@..._rcv_core'
The second issue is certain -Wframe-larger-than warnings that appear
with clang versions prior to 19, which introduced an optimization that
produces much better code:
# Link: https://github.com/llvm/llvm-project/commit/90ba33099cbb17e7c159e9ebc5a512037db99d6d [2]
clang-18:
drivers/media/pci/saa7164/saa7164-core.c:605:20: error: stack frame size (2392) exceeds limit (2048) in 'saa7164_irq' [-Werror,-Wframe-larger-than]
605 | static irqreturn_t saa7164_irq(int irq, void *dev_id)
| ^
clang-19:
drivers/media/pci/saa7164/saa7164-core.c:605:20: error: stack frame size (216) exceeds limit (128) in 'saa7164_irq' [-Werror,-Wframe-larger-than]
605 | static irqreturn_t saa7164_irq(int irq, void *dev_id)
| ^
Restrict the testing of the availability of '-march=native' to all
supported GCC versions and clang-19 and newer to avoid these known
resolved issues.
Fixes: 0480bc7e65dc ("x86/kbuild/64: Add the CONFIG_X86_NATIVE_CPU option to locally optimize the kernel with '-march=native'")
Signed-off-by: Nathan Chancellor <nathan@...nel.org>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Cc: Nick Desaulniers <ndesaulniers@...gle.com>
Cc: Tor Vic <torvic9@...lbox.org>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Brian Gerst <brgerst@...il.com>
Cc: Juergen Gross <jgross@...e.com>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: Kees Cook <keescook@...omium.org>
Cc: Josh Poimboeuf <jpoimboe@...hat.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Link: https://lore.kernel.org/r/20250324-x86-march-native-clang-19-and-newer-v1-1-3a05ed32a89e@kernel.org
---
arch/x86/Kconfig.cpu | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index 87bede9..f928cf6 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -248,6 +248,12 @@ endchoice
config CC_HAS_MARCH_NATIVE
# This flag might not be available in cross-compilers:
def_bool $(cc-option, -march=native)
+ # LLVM 18 has an easily triggered internal compiler error in core
+ # networking code with '-march=native' on certain systems:
+ # https://github.com/llvm/llvm-project/issues/72026
+ # LLVM 19 introduces an optimization that resolves some high stack
+ # usage warnings that only appear wth '-march=native'.
+ depends on CC_IS_GCC || CLANG_VERSION >= 190100
config X86_NATIVE_CPU
bool "Build and optimize for local/native CPU"
Powered by blists - more mailing lists