]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
kbuild: expand inlining hints with -fdiagnostics-show-inlining-chain
authorJustin Stitt <justinstitt@google.com>
Tue, 31 Mar 2026 00:09:08 +0000 (17:09 -0700)
committerNicolas Schier <nsc@kernel.org>
Tue, 7 Apr 2026 19:48:44 +0000 (21:48 +0200)
Clang recently added -fdiagnostics-show-inlining-chain [1] to improve
the visibility of inlining chains in diagnostics. This is particularly
useful for CONFIG_FORTIFY_SOURCE where detections can happen deep in
inlined functions.

Add this flag to KBUILD_CFLAGS under a cc-option so it is enabled if the
compiler supports it. Note that GCC does not have an equivalent flag as
it supports a similar diagnostic structure unconditionally.

Link: https://github.com/llvm/llvm-project/pull/174892
Link: https://github.com/ClangBuiltLinux/linux/issues/1571
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Link: https://patch.msgid.link/20260330-kbuild-show-inlining-v2-1-c0c481a4ea7b@google.com
Signed-off-by: Nicolas Schier <nsc@kernel.org>
Makefile

index a8d8ed711f9b3e3f1f109a34c71fbdbe2e883fde..c9d6f84ff489150b70b16d8ac88a326917995cdc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -987,6 +987,10 @@ KBUILD_CFLAGS      += $(call cc-option, -fno-stack-clash-protection)
 # Get details on warnings generated due to GCC value tracking.
 KBUILD_CFLAGS  += $(call cc-option, -fdiagnostics-show-context=2)
 
+# Show inlining notes for __attribute__((warning/error)) call chains.
+# GCC supports this unconditionally while Clang 23+ provides a flag.
+KBUILD_CFLAGS  += $(call cc-option, -fdiagnostics-show-inlining-chain)
+
 # Clear used registers at func exit (to reduce data lifetime and ROP gadgets).
 ifdef CONFIG_ZERO_CALL_USED_REGS
 KBUILD_CFLAGS  += -fzero-call-used-regs=used-gpr